Update
The scenario is now fully explained in : http://www.windowsazure.com/en-us/manage/services/notification-hubs/notify-users-aspnet/
The solution below does not work anymore as Notification Hubs is out of preview and there were some breaking changes in the .NET SDK.
Old answer
The solution you outlined is correct. The caveat is that when doing registration mgmt from the app back-end you have to store the token currently registered somewhere (usually in the device app, but in an installation table in the back-end works too).
Assuming you are storing the 'old' token on the device, you have to implement the following logic.
In the back-end
An endpoint that takes two parameters: 'oldToken', 'newToken'. This basically, either creates a new registration (change template/native or tags as needed), or updates the current one.
var hubClient = NotificationHubClient.CreateClientFromConnectionString(connectionString, "<notification hub name>");
if (hubClient.RegistrationExists("oldDeviceToken"))
{
hubClient.UpdateRegistrationsWithNewPnsHandle("oldDeviceToken", "newDeviceToken");
} else
{
hubClient.CreateAppleNativeRegistration("newDeviceToken", new string[] {"myTag"});
}
More scenarios are possible where you modify current registrations, add tags, modify templates... On hubClient you have all those methods and they are self explanatory. Some high level info is at the end of this article.
In the device app
Implement the following logic:
- If there is no old token stored, contact the back-end with the new token (backendEndpoint(newToken, newToken)), when it returns store the token locally
- If there is an old token, and it different than the new one, contact the back-end with old and new token (backendEndpoint(oldToken, newToken)), when the calls completes store the new token locally.
- If there is an old token and it is no different than the new one, but the last registration happened more than 30 days ago, call the back-end with the old token (backendEndpoint(oldToken, oldToken)).
We will add a sample for this scenario asap.