2

我很難實現這個目標。我正在開發一個PhoneGap應用程序,我將把它部署到Android,iOS和Windows Phone。如何在Windows Phone的Microsoft推送通知服務中進行身份驗證?

我能夠毫無問題地使用Apple通知服務(APN)和Google Cloud Messaging,但是我的確遇到了一些麻煩,試圖對我的Windows Phone應用程序進行相同操作。

與APN不同,我找不到一個地方來生成一些代碼或下載一些證書來將我的應用程序與推送通知服務集成。

我想使用此服務推送通知發送到Windows Phone與PHP http://phpwindowsphonepush.codeplex.com/

的例子顯示了我這個$uri="http://db3.notify.live.net/throttledthirdparty/01.00/123456789123456798"; //uri sended by Microsoft plateform但我怎麼註冊到他們plataform爲了得到一個URI像這樣的?

另外,這是PHP Windows Phone推送在Windows Phone上發送Toast和磁貼通知的正確選擇嗎?該文檔非常混亂,並不清楚如何配置服務器和本地代碼應用程序,我迷路了。

回答

3

被叫通知通道中的URI,它是APNS設備令牌和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消息),但建議這樣做:

我們建議設立一個認證網絡服務,因爲通信 發生在一個HTTPS接口,更好的安全性你 通知發送到推送通知服務。經過身份驗證的網絡 服務對其可發送的推送通知的數量 沒有每日限制。另一方面,未經身份驗證的Web服務是 ,每個訂閱每個訂閱500個推送通知的速率受到限制,每個訂閱日期爲 。有關更多信息,請參閱設置已通過身份驗證的Web服務,以 發送Windows Phone的推送通知。

相關鏈接:

Sending push notifications for Windows Phone

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

+0

現在我明白了。非常感謝你。所以根本沒有Windows Phone的註冊過程?只需將URI發送到服務器? – steps

+0

@JoãoPauloApolinárioPassos如果您希望使用經過身份驗證的Web服務發送推送通知,則必須遵循一些註冊過程(請參閱我的答案底部的鏈接)。否則,您可以簡單地將通知數據發佈到URI。 – Eran

相關問題