Callback for phone contacts modification - windows-phone-8

Does WP8 have any OS hook or callback (sync mechanism) I can implement to get a notification when a contact changes?
For example I'm running an application as a background agent, and a user randomly changes a contact's details. I want to get notified in my background engine so that I can do various operations.
I could always implement a periodic check (say every minute I read all contacts and check to see if there are any modifications - assuming I'm remembering the last configuration somehow). But this solution is not efficient for a large number of contacts, especially when I want the application to run on the low end phones.

Windows Phone does not support any built in way for applications to be notified of contact changes.
As you've noted, the only way to do this would be to track the details and periodically look for differences. Yes, you'd have to do this with the app running (rather than a background agent) if you want to support WP7 devices with one 256MB of memory.
As an alternative and assuming that the user is syncing their contacts with their live.Windows account you could create an external service that periodically polls their live account (via http://msdn.microsoft.com/en-us/live/ff519582.aspx) for changes and then send a notification to the device/app regarding the change.

Related

When is it OK to retire your old API

I don't know whether this question belongs to SO or UX (or Programmers.SE) but here it goes.
We have built a mobile app a couple of months back, which we intend to alter in some major ways (like authentication and security) in next release. We published it to AppStore/PlayStore and it has a download count between 5k-10k range.
Now the question is;
whether if we retire our current API rightaway and show current version users a popup which forces them to update the app (via stores)
or
create a new API under a different URL and maintain both APIs at the same time (in this case should we maintain it forever or should we set up an expiration date) ?
EDIT:
It'll be our first and possibly last update, since our app is a cordova based hybrid app, we intend to use silent cloud deployments without relying on app stores.
I would say - for a mobile application, forcing your users to upgrade straight away isn't a unreasonable expectation. The exception to that is if you have users on an older operating system (e.g. old iOS) that cannot upgrade. Then you might want to maintain a legacy API.
Can you give a legitimate reason why a reasonable user wouldn't be prepared to update your app?

Create A background service in Windows phone 8 to update location

I have to create a Background Task which should run after every 1 minute and should call a Rest service to update the Mobile longitude and Latitude Location. The rest service for this purpose have been written all I have to do is to write a Task in my existing application which should perform this update. Can you guys please tell which is the most easiest way to implement this functionality.
Thanks,
There isn't a concept of a service like exists in Windows Desktop. Applications are running, or not on the phone. One application on the phone, tracking location, can be running in the background while other applications run.
If your application is in the foreground, you will just directly call the web services with updated location.
You can use a scheduled background agent to periodically update location, but it is likely that it won't update frequently enough for your needs.
MSDN has details about how to create an application that actively tracks location in the background, subject to some important limitations, and reasons the application may be deactivated:
The app stops actively tracking location. An app stops tracking location by removing event handlers for the PositionChanged and StatusChanged events of the Geolocator class or by calling the Stop() method of the GeoCoordinateWatcher class.
The app has run in the background for 4 hours without user interaction.
Battery Saver is active.
Device memory is low.
The user disables Location Services on the phone.
Another app begins running in the background.
In addition, there is a complete tutorial available for this scenario.

How does the CurrentApp.ReportProductFulfillment method work?

I'm testing my Windows Phone 8 app for scenarios where my app goes to the background before it can fulfill a consumable purchase. So, on every app-launch I check if there are any unfulfilled in-app purchases, if there are, I fulfill them using the CurrentApp.ReportProductFulfillment method.
However, while testing I noticed this method works even if the device isn't connected to the Internet. So how and when does the app let the Marketplace know that the purchase has been successful? More importantly, should I only do this only if I have an Internet connection?
This is my code by the way :
var licenses = CurrentApp.LicenseInformation.ProductLicenses;
if (licenses["PRODUCT_ID"].IsConsumable && licenses["PRODUCT_ID"].IsActive) {
// Fulfill consumable purchases
// Let the Marketplace know
CurrentApp.ReportProductFulfillment("PRODUCT_ID");
}
Marketplace communications occur on a background task spawned by the OS on regular intervals. You can observe this traffic if you attach Fiddler to a machine running Windows Phone emulator
The following statements are merely suppositions on my part, so take it with a grain of salt. I would imagine the background Marketplace communication handles a number of tasks. The most common of these would be checking for application updates. However, this would also be an ideal time for the OS to communicate fulfillment of an order. In that vein, Marketplace services likely queue your report request and, if it cannot be communicated immediately, defers it for the background task to handle at a later time, allowing the method to run even when the phone does not have data access. Given the nature of modern cashless transactions, I don't see any reason the Marketplace would require immediate notification of fulfillment, as it has time to complete a transaction once initialize authorization is acquired.
CurrentApp.LicenseInformation.ProductLicenses is cached by the windows phone operating system.

AIR 3.5 Mobile project device ID

I am wondering if someone knows the best method for storing data in a global DB against a mobile device (iOS and Android)?
I am building an app that writes/retrieves information based on a query however I need to know if any of the records returned were sent from that device.
Basically the idea is that if a user submits some information (which is stored in the DB) they gain access to additional features of the app. When the app is launched, I will check the DB to see if they submitted information in the past and allow access to other areas.
I use local storage for the information they submitted but also store remotely so if the local storage becomes corrupted for any reason there is still a record of the information the user submitted.
The ID needs to be unique to the device as there could be 100 of users (hoping for millions) so the ID needs to be unique enough that it will never conflict with another device. Any information submitted will be available for retrieval by all other users.
Thanks :)
There are three options as I see it:
1. User
You can create a typical username + password user scheme and use this to verify the user. A possible advantage of this method would be that the user can log in from any of their devices (for instance, under your method a user using the app from their iPhone and iPad would have two different views - which you may not want). Of course, this means forcing every user of the app to register within your system, which is not ideal.
2. App Install
You can uniquely identify an app install by having your app generate a UUID the first time that the app is run (you can use an AS3 helper library to generate the UUID). You can store this UUID locally and send it along with every request the app makes. The downside to this approach is that it doesn't uniquely identify the device - only a specific app install. For instance, if the user deletes the app and then reinstalls it at a later point, it will now count as a new unique device, even though the user is on the same device.
3. Device
AIR does not have a built-in way of reading device identifying info. However, you can retrieve device info through AIR Native Extensions, for example this one can get the MAC address and some other things. There are privacy concerns and other issues involved in reading and storing device info such as these, so you are probably best served trying to implement the OpenUDID project as an AIR Native Extension, since they have already dealt with all such issues. Unfortunately, I have never looked too far into developing ANE's so I am not sure how complicated or feasible it will be to turn OpenUDID into an ANE.
Summary: I would recommend the app install method due to the ease of implementation. If you really need the unique device and are worried about the multiple app installs case, you will have to work out how to use native extensions to get the info you need. If you decide that you would rather identify by user rather than device, use the user method.
As of now I don't think its possible to get the hardware devices guid using air mobile. However you do have a couple of options.
If the MAC address is good enough for you there is an ANE that will let you grab it on both iOS and Android.
http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/networkinfo.html
and an example of how to use it
http://cookbooks.adobe.com/post_Getting_NetworkInfo_from_both_Android_and_iOS-19473.html
You could also write your own ANE, it should be pretty simple to wrap both Android and iOS implementations.
Objective-c: [[UIDevice currentDevice] uniqueIdentifier]
Android: TelephonyManager.getDeviceId()
If your app requires any kind of user account or login the best option would be to store this setting in the remote db.

windows phone 8: how to check if there are new messages on the database (server) all the time (even if the app is not running)?

I’ve been developing Windows desktop applications for many years, but just started developing Windows Phone 8 applications so, as you can imagine, I have many questions and doubts.
This is my problem so far:
I need an application to check any certain time if there are new messages / notifications in the server database, even if the application is not running, and show it (in some way, not sure how) on the phone. At the end, I want something similar to Facebook application (or others) that checks constantly if there are new messages even if I’m not using the phone.
How can I do that? Is there any tutorial or guide that explains that?
Thank you very much
There's two mechanisms available on Windows Phone to periodically check a data source and display notifications:
Push notifications: the server directly sends the notification to the phone. It provides the best user experience, because the notification is send (nearly) instantaneously, and because all the processing is done server-side (so it doesn't impact the phone's autonomy). The obvious drawback is that you need a server infrastructure to send the notifications.
Background agents: your application runs in background, is woke up periodically (every 30 minutes or so), and is allowed to run for about 15 seconds. During those 15 seconds, you can check your data source, and display a notification if needed. The two major drawbacks are that you can't choose when you're background agent executes (so the notification can be displayed 30 minutes late), and it'll have an impact on the battery life.
What you need is push notifications.
Microsoft already provides this functionality throught Azure Mobile Services and here is something to get you started : Get started with push notifications in Mobile Services