4

我正在尝试按照http://msdn.microsoft.com/en-us/library/windows/apps/hh913756.aspx在 Windows8 中编写推送通知示例。我已将我的应用与商店关联,并收到了该应用的通知渠道。但是当我将它传递给我的云服务(这只是一个从查询字符串中获取通道 URI 的网站)以获取访问令牌时,HTTP 请求总是超时。但是当我尝试使用 SID 和 SecretKey 从应用程序中获取访问令牌时,它会成功。当我尝试使用http://31daysofwindows8.com/push为了进行测试,我收到了一个异常“频道 URL 与调用者应用程序不兼容”。据我了解,云服务不需要与商店关联或配置推送通知,它所需要的只是 SID 和 SecretKey 来获取访问令牌。不确定我的假设/理解是否错误。

谢谢, 索里亚

4

2 回答 2

4

使用 Cordova for Windows,我发现应用程序应该通过菜单命令“存储”->“将应用程序与应用程序关联...”与 Windows 应用商店中的应用程序相关联。

但是即使在“Store”->“Associate App with the Store...”之后,推送消息也无法传递。

问题是,该应用程序仍然分配了默认的 CordovaApp_TemporaryKey.pfx。

在我将新的 CordovaApp.Windows_StoreKey.pfx 复制到 CordovaApp_TemporaryKey.pfx 后,消息传递成功。

于 2015-07-28T12:18:15.043 回答
2

I just tested out the http://31daysofwindows8.com/push and it worked fine for me. The cloud service does need the SID and key to authenticate with WNS on behalf of your application, so in that sense they are associated, but for the http://31daysofwindows8.com the association was quite temporary as you just enter them in as input (and be aware they are in clear text with that tool).

You would need to use the URI you got from your Windows 8 app (via CreatePushNotificationChannelForApplicationAsync) using exactly the same SID and key that you are using to obtain the OAuth access token. All that would be appropriately setup for you when you associated that app with the profile in your store dashboard.

It sounds like this is just what you did, but the error you're getting has the hallmark of trying to use a channel URI obtained with one SID/Key to send a notification authenticated with a different SID/Key. Note that if you're uninstalling and reinstalling your Win 8 app (an option on the Debug tab in Visual Studio), this will also invalidate a previously obtained URI; however, in my case, the 31daysofwindows8 site reported a revoked URI, not a "incompatible" one.

As for your cloud service that times out, are you url-encoding the URI when you send it up?

Lastly, it's a bit of a tangent from your specific question, but if you haven't looked at Windows Azure Mobile Services, its role is precisely to take away the pain of rolling your own service to do all this. There's a completely free tier and there's always the ability to add more horsepower when your app goes wildly successful.

于 2013-06-15T04:07:17.510 回答