NotificationHub Push Notification 返回:从 Token Provider 获取的 Token 错误 [英] NotificationHub Push Notification returns : The Token obtained from the Token Provider is wrong

本文介绍了NotificationHub Push Notification 返回:从 Token Provider 获取的 Token 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 Wp8.1 Silverlight 应用程序,它从 Mobileservice(旧的 azure 服务)接收推送通知 (WNS).

因此,由于有新功能,我想更新到新服务.我现在已经创建/升级了一个新服务器以使用应用服务 - 移动应用.并使用来自 azure 的示例应用程序测试了推送通知(一切正常).

回到我的应用程序 WP8.1 -> 通过 NuGet (2.0.1) 添加新包 Microsoft.Azure.Mobile.Client,存在 Microsoft.WindowsAzure.Mobile 的问题.Ext 不包含GetPush"扩展名.好像少了它?看WP8版本,它只注册到MPNS,我需要WNS.所以我不知道是否可以使用任何其他组件.

我可以添加另一个程序集引用吗?

更新

下面的代码让我在服务器上注册设备,我可以看到设备注册正确.其中 channelUriinstallationInformation 由客户端检索并发送到服务器.

安装ins = new Installation();ins.Platform = NotificationPlatform.Wns;ins.PushChannel = uTagAndChan.ChannelUri;ins.Tags = uTagAndChan.Tags;ins.InstallationId = uTagAndChan.installationInformation;等待 hubClient.CreateOrUpdateInstallationAsync(ins);

向已注册的标签发送测试 toast-notification,导致以下错误:

<块引用>

从Token Provider获取的Token错误

搜索此问题时,我发现

使用

完成 URI 检索

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

在描述中指出它返回一个 WNS.这似乎推断我在服务器上进行的注册(顶部的代码片段)是正确的,而客户端上的注册是错误的.

但是图像上的注册似乎是错误的.两个注册的 PNS Identifier 不应该不同吗?expiration date 似乎也错了?

由于 NuGet 包中不存在 GetPush()(在示例中可用于正确注册客户端以获取通知),如何解决此问题?

更新

我读过一个地方,删除和重新创建 NotificationHub 可能会有所帮助.我今天会试试这个.即使它有效,也更希望有解决方案,并知道注册是否正确完成?

临时解决方案:

删除、重新创建、插入包 SID 和秘密.它再次起作用(奇怪)!

仍然对潜在问题感兴趣!

解决方案

删除并重新创建服务,设置所有相同的设置使其再次工作.

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:

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!

解决方案

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

这篇关于NotificationHub Push Notification 返回:从 Token Provider 获取的 Token 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆