windows-phone-7 - 如何在适用于 Windows Phone 的 Microsoft 推送通知服务中进行身份验证?

标签 windows-phone-7 windows-phone-8 push-notification windows-phone mpns

要实现这个目标我真的遇到了麻烦。我正在开发一个 PhoneGap 应用程序,并将其部署到 Android、iOS 和 Windows Phone。

我能够毫无问题地使用 Apple 通知服务 (APN) 和 Google 云消息传递,但在尝试对我的 Windows Phone 应用程序执行相同操作时却遇到了麻烦。

与 APN 和 GCM 不同,我找不到地方来生成一些代码或下载一些证书来将我的应用程序与推送通知服务集成。

我正在尝试使用此服务通过 PHP 向 Windows Phone 发送推送通知 http://phpwindowsphonepush.codeplex.com/

该示例向我展示了这个 $uri="http://db3.notify.live.net/throttledthirdparty/01.00/123456789123456798";//uri 由 Microsoft 平台发送,但是我如何注册到他们的平台中才能获得像这样的 URI?

此外,这个 PHP Windows Phone Push 是在 Windows Phone 上发送 toast 和平铺通知的正确选择吗?该文档非常困惑,并且不清楚如何配置服务器和 native 代码应用程序,我迷失了。

最佳答案

被调用通知 channel 中的 URI,它是 APNS 设备 token 和 GCM 注册 ID 的 MPNS 等效项。 您可以在 Windows Phone 应用程序代码中获取它:

public MainPage()
{
    /// Holds the push channel that is created or found.
    HttpNotificationChannel pushChannel;

    // The name of our push channel.
    string channelName = "ToastSampleChannel";

    InitializeComponent();

    // Try to find the push channel.
    pushChannel = HttpNotificationChannel.Find(channelName);

    // If the channel was not found, then create a new connection to the push service.
    if (pushChannel == null)
    {
        pushChannel = new HttpNotificationChannel(channelName);

        // Register for all the events before attempting to open the channel.
        pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
        pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

        // Register for this notification only if you need to receive the notifications while your application is running.
        pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

        pushChannel.Open();

        // Bind this new channel for toast events.
        pushChannel.BindToShellToast();

    }
    else
    {
        // The channel was already open, so just register for all the events.
        pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
        pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

        // Register for this notification only if you need to receive the notifications while your application is running.
        pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

        // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
        System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
        MessageBox.Show(String.Format("Channel Uri is {0}",
            pushChannel.ChannelUri.ToString()));

    }
}

您不必验证您的 Web 服务(未经验证的 Web 服务每天每台设备可以发送 500 条消息),但建议您这样做:

We recommend setting up an authenticated web service to send your notifications to the push notification service because communication occurs over an HTTPS interface for better security. Authenticated web services do not have a daily limit on the number of push notifications they can send. Unauthenticated web services, on the other hand, are throttled at a rate of 500 push notifications per subscription per day. For more info, see Setting up an authenticated web service to send push notifications for Windows Phone.

相关链接:

Sending push notifications for Windows Phone

Setting up an authenticated web service to send push notifications for Windows Phone

关于windows-phone-7 - 如何在适用于 Windows Phone 的 Microsoft 推送通知服务中进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15703829/

相关文章:

c# - windows phone 8中如何监听scrollviewer的滚动事件?

windows-phone-8 - 无法保留 IsolatedStorageSettings 数据 (C#)

java - 使用 Parse 从应用程序引擎发送推送通知

ios - 完成启动后或在我们的应用程序内启用/禁用推送通知

silverlight - 透明强调色

silverlight - WP7 的文本框验证

c# - 获取 "Operation not permitted on IsolatedStorageFileStream."错误

c# - 制作一个控件以沿着集合一次滑动一个图像,Windows Phone 7

javascript - WP8 上的 Cordova : requirejs can't resolve views

android - meteor raix :push notification channelId for android 8. 0.0