7

Now I'm using PushSharp library to send Apple push notifications (through APNS), but I want to migrate to Notification Hubs for robustness and scalability.

I'm planning to implement sending notification via Azure Notification Hubs using backend registration as described in this article. So:

  1. There is a method of backend API that an iOS client calls when it has push token updated. In this method I do the registration tagging it with user id. (Previously, I stored push token to user link in DB.)
  2. When I have some notification to send for a specific user I send it using the tag (user id). (Previously, I used APNS device token from DB.)

It seems like a working solution, but in Notification Hubs documentation it's said:

It is important to note that registrations are transient. Similar to the PNS handles that they contain, registrations expire. You can set the time to live for a registration on the Notification Hub, up to a maximum of 90 days. This limit means that they must be periodically refreshed, and also that they should not be the only store for important information. This automatic expiration also simplifies cleanup when your mobile application is uninstalled.

And that is the problem. Sometimes I need to send notification to devices that haven't updated the token for 90 days and so forth the registration. So the APNS token will still be active, but Notification Hub's registration will be invalidated. So I just lose the communication channel for the user.

How do you handle this?

Of course, I can still store tokens in DB and make a job that updates registrations periodically. But that's not what you expect from a push notification solution like Notification Hubs.

3 Answers 3

6

You can either refresh your registrations from the application or from your server. If you do it from your application, the app must be launched by the user in order for the registration to be refreshed.

Therefore, if you require that device registrations remain active even for apps that weren't launched for over 90 days, you have to refresh the registration via your server, and running a job in your server that would refresh the tokens seems like your only option.

I agree that Notification Hubs' decision to expire the tokens seems strange. Perhaps they had in mind the behavior of MPNS (Microsoft Push Notification Service) notification channels, which expire more often than APNS device tokens or GCM registration IDs.

1
  • 1
    What would the implementation for a server-side registration refresh look like? Not looking for specifics, just a general direction. Thanks. Nov 25, 2015 at 21:40
4

Just a quick note, since the answer is 2 years old. In this blogpost Azure states:

It is important to note that registrations and installations by default no longer expire.

I assume that this makes the expire field confusing, but not a problem anymore.

UPDATE

Older notification hubs still have this issue. You need to update them to set the expiry to infinity, instructions are found in this forum post. New hubs are automatically set to infinity.

0

As per latest notification hub documentation, this 90 days limit has increased to lifetime, which means you don't need to re register device after 90 days.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.