Search code examples
push-notificationazure-web-app-serviceazure-mobile-servicesazure-notificationhub

NotificationHub Push Notification returns : The Token obtained from the Token Provider is wrong


I have Wp8.1 Silverlight app that receives push notification (WNS) from Mobileservice (the old azure service).

I therefore wanted to update to the new service because of the new features. I have now created/upgraded a new server to use App Service - Mobile App. And tested push notification with the sample app from azure (everything works).

Going back to my app WP8.1 -> Adding the new package Microsoft.Azure.Mobile.Client through NuGet (2.0.1), there is the issue that the Microsoft.WindowsAzure.Mobile.Ext does not contain the 'GetPush' extension. It seems like it is missing it? looking to the WP8 version, it only registers to MPNS, and I need WNS. So I do not know if any other assembly could be used.

Can I add another assembly reference?

Update

The following code lets me register the device on the server, and I can see the device register correctly. where the channelUri and the installationInformation are retrieved by the client and send to the server.

Installation ins = new Installation();
ins.Platform = NotificationPlatform.Wns;
ins.PushChannel = uTagAndChan.ChannelUri;
ins.Tags = uTagAndChan.Tags;
ins.InstallationId = uTagAndChan.installationInformation;
await hubClient.CreateOrUpdateInstallationAsync(ins);

Sending a test toast-notification to the registered tags, results in the following error :

The Token obtained from the Token Provider is wrong

Searching on this issue I found Windows Store App Push Notifications via Azure Service Bus. Which the proposed solution says to register to the notification hub directly from the app, I would rather not have the app to have directly access to the hub. But is this the only way? (mind you the answer was not accepted, but I will try it all though it is not a desired solution)

Update

Registering for notifications via client (WP8.1 Silverligt), makes a registration to MPNS, which I do not want.

The snippet on the server registers a WNS, the two registrations can be seen here:

Example of the registrations

The URI retrieval is done using

var channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

which in the description states it returns a WNS. This seems to infer that the registration I am doing on the server (code snippet in the top) is correct and the registration on the client is faulty.

But the registration on the image seems wrong. Shouldn't the PNS Identifier be different for the two registrations? also expiration date seems wrong ?

How to mend this since the GetPush() (which was available in the sample registered the client correctly for notifications) does not exist in the NuGet package?

Update

I read one place that deleting and recreating the NotificationHub could help. I will try this today. Even IF it works, it would be more desirable to have the solution, and to know if the registrations are done correctly?

Temporary solution:

Deltede, recreated, inserted Package SID and Secret. And it works again (strange)!

Still interested in the underlying issue!


Solution

  • Deleted and recreated the service, setting all the same settings made it work again.