gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:04:31 24 4
gpt4 key购买 nike

我真的很难实现这个目标。我正在开发一个 PhoneGap 应用程序,我也打算将它部署到 Android、iOS 和 Windows Phone。

我可以毫无问题地使用 Apple 通知服务 (APN) 和 Google Cloud Messaging,但是我在尝试使用 Windows Phone 应用程序做同样的事情时真的很糟糕。

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

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

该示例向我展示了这个 $uri="http://db3.notify.live.net/throttledthirdparty/01.00/123456789123456798"; //uri sended by Microsoft plateform 但我如何注册到他们的平台以获得这样的 URI?

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

最佳答案

该 URI 称为通知 channel ,它是 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com