2013-10-01 46 views
0

嗨,我正在開發Windows Phone 8.我需要發送和接收使用PHP的磁貼推送通知。我的設備上未收到平鋪推送通知。我收到下面給出的錯誤。誰能告訴我爲什麼我面臨這個問題?Windows Phone平鋪推送通知不會收到?

錯誤:

HTTP/1.1 200 OK Cache-Control: private Server: Microsoft-IIS/7.5 X-DeviceConnectionStatus: Connected X-NotificationStatus: Suppressed X-SubscriptionStatus: Active X-MessageID: 00000000-0000-0000-0000-000000000000 ActivityId: d4a926a3-345c-432f-9a96-2f9c62ce8013 X-Server: DB3MPNSM036 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Tue, 01 Oct 2013 09:08:33 GMT Content-Length: 0

我使用的代碼如下:

HttpNotificationChannel pushChannel; 

     // The name of our push channel. 
     string channelName = "TileSampleChannel"; 
     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); 

      pushChannel.Open(); 

      // Bind this new channel for Tile events. 
      pushChannel.BindToShellTile(); 


     } 
     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); 

      // 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())); 

     } 





void PushChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e) 
    { 

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

     }); 
    } 
    void PushChannel_ErrorOccurred(object sender, NotificationChannelErrorEventArgs e) 
    { 
     // Error handling logic for your particular application would be here. 
     Dispatcher.BeginInvoke(() => MessageBox.Show(String.Format("A push notification {0} error occurred. {1} ({2}) {3}",e.ErrorType, e.Message, e.ErrorCode, e.ErrorAdditionalData))); 
    } 

回答

0

下面介紹一下MPNS docs對你說了(200 OK,禁止,連接的活動)的響應:

The push notification was received and dropped by the Push Notification Service. The Suppressed status can occur if the notification type was not enabled by calling BindToShellTile or BindToShellToast in the client application, if the raw notification was sent when the application was not in the foreground or if a Tile notification was sent with no Tile for the application pinned to start.

我看到你確實打電話給BindToShellTile,而且你沒有發送生通知,所以也許最後一個選項適用 - a Tile notification was sent with no Tile for the application pinned to start