5

A stored notification channel URI may go stale while my app is inactive -- i.e., stopped, tombstoned or dormant. What is the best practice for updating the channel URI with my web service after a period of inactivity?

Various articles on the web mention "retrieving" the URI in order to send it to the web service. But as far as I can tell, the only way for my app to learn the channel URI is via the ChannelUriUpdated event on HttpNotificationChannel, and raising that event is not under my control. MPNS may have changed the URI while my app was inactive. If the app could not respond to ChannelUriUpdated, the URI would then be stale in both my app and my web service.

Perhaps a channel returned by HttpNotificationChannel.Find is guaranteed to always have an up-to-date channel URI?

Eran
  • 387,369
  • 54
  • 702
  • 768
lencharest
  • 2,825
  • 2
  • 15
  • 22
  • To clarify, I am not asking how to track the channel URI in general. I am asking how to _ensure_ that the channel URI is up-to-date immediately _after_ the app wakes up from a period of inactivity (e.g., tombstoning). – lencharest Jun 05 '12 at 17:51
  • When your app wakes up from tombstoning, if your current channel has became invalid, you will get null NotificationChannel.ChannelUri. In that case, just notify to your webservice and wait to get new link from ChannelUriUpdated. There is no way to pull a new Channel URI from MPNS. – David To Jul 12 '13 at 09:51

2 Answers2

0

General best practice is to request the current channel Uri whenever the app is started. Within the app you should keep track of the last value returned (across application invocations) and if it's changed to upload to your web service.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
  • How do you request the channel URI? ChannelUriUpdated event lets MPNS push a new value to the app, but how do I "pull" the current URI from MPNS? I don't see an API for that. – lencharest May 23 '12 at 21:03
  • Upon further reflection, I'm wondering if you mean I should simply get the Http.NotificationChannel.ChannelUri property. – lencharest May 24 '12 at 17:00
  • @lencharest I guess you will have to store in isolated memory the new URI everytime you get fired the ChannelUriUpdated event. Then as a never ending cycle, your last saved channel Uri is the "current" and the new channel reflected in the notification event is the new one. Compare, and if they are different, notify your webservice. – Adrian Salazar May 26 '12 at 16:52
0

Please follow this Updated document here. what it does is, it executes a script on insert of the channel uri, it checks if the channel URI exits, if it exists it does not insert the record, else it inserts the record. so, once the channel uri for a device expires, a new channel uri is given to the device in that case, the comparision mismatches and the new channel uri is inserted. by doing that the device is always sent the notification.

Note:- to leverage that functionality, you have to send for insert every time your app starts. hope this helps.

AMS
  • 550
  • 6
  • 22