简体   繁体   English

设备上的Windows Phone推送通知

[英]Windows Phone Push Notifications on a Device

I'm trying to create push notifications for my Windows 8 phone app. 我正在尝试为Windows 8手机应用程序创建推送通知。 I'm using the example from Microsoft (code and demo video links below) which works fine through the emulator but when I debug to the device instead the app runs but never connects to the WPF app which sends the notification. 我正在使用Microsoft的示例(下面的代码和演示视频链接),该示例可通过仿真器正常运行,但是当我调试设备时,该应用将运行,但从不连接到发送通知的WPF应用。 The emulator works fine every time however. 仿真器每次都可以正常工作。 I'm making sure to do the following; 我确保执行以下操作;

  • VS has to be in Administrator mode for the WPF app VS必须在WPF应用程序的管理员模式下
  • In the phone app, in the method SubscribeToService() I've changed the address to the name of my pc; 在电话应用程序中,在方法SubscribeToService()中,我已将地址更改为我的PC的名称。 string baseUri = "http://MY-PC-NAME:8000/RegistrationService/Register?uri={0}";
  • I'm always running the WPF app before the Phone app 我总是先运行WPF应用程序,然后再运行Phone应用程序
  • I have my firewall turned off to allow access to port 8000 我关闭了防火墙,以允许访问端口8000

Is there something extra I have to do to get the app to work on an actual device? 为了使该应用程序在实际设备上运行,我还需要做些额外的事情吗?

http://code.msdn.microsoft.com/Windows-Phone-8-JumpStart-ab6c839a http://code.msdn.microsoft.com/Windows-Phone-8-JumpStart-ab6c839a

http://channel9.msdn.com/Series/Building-Apps-for-Windows-Phone-8-Jump-Start/Building-Apps-for-Windows-Phone-8-Jump-Start-08-Push-Notifications http://channel9.msdn.com/Series/Building-Apps-for-Windows-Phone-8-Jump-Start/Building-Apps-for-Windows-Phone-8-Jump-Start-08-Push-Notifications

I ended up using an ASP.NET webform insead of WPF and didn't have any problems. 我最终使用了WPF的ASP.NET Web表单,没有任何问题。 See the link below. 请参阅下面的链接。 I just added functionality between the phone and the webform provided. 我只是在电话和提供的网络表单之间添加了功能。 When "Subscribing to Service", as you state in your question (ie, sending the Device URI to the web service, to send the push notification), I just used the address given from ASP.NET when running the webform (ie, hit run, and use the address in the address bar). 当您在问题中指出(例如,将设备URI发送到Web服务以发送推送通知)时,“订阅服务”时,我只是在运行Web表单时使用了ASP.NET提供的地址(即,点击运行,然后使用地址栏中的地址)。 This should work locally on your machine. 这应该在您的计算机上本地工作。

Hope this helps, I've pasted the sample project below from the MSDN samples. 希望对您有所帮助,我从MSDN示例中粘贴了以下示例项目。

http://code.msdn.microsoft.com/Toast-Notification-Sample-fb20ae13 http://code.msdn.microsoft.com/Toast-Notification-Sample-fb20ae13

确保从发送推送消息的服务器打开了TCP端口号2195出站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM