我正在尝试将推送通知发送到我的寡妇手机 8 应用程序(平铺通知)。这是来自 MPNS 的响应:通知状态:抑制 notificationChannelStatus :Active, deviceConnectionStatus:Connected。我检查了服务器响应代码,我发现了以下解释:
推送通知服务已接收并删除了推送通知。如果未通过在客户端应用程序中调用 BindToShellTile 或 BindToShellToast 启用通知类型,则可能会出现 Suppressed 状态
这是我在客户端的代码,我正在调用BindToShellTile
方法 - 它在第一次安装应用程序时被调用。
HttpNotificationChannel pushChannel;
string channelName = "TileSampleChannel";
pushChannel = HttpNotificationChannel.Find(channelName);
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();
pushChannel.BindToShellTile();
} else {
pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
MessageBox.Show(String.Format("Channel Uri is {0}",
pushChannel.ChannelUri.ToString()));
}
而且我能够成功获取频道 URI。为什么我总是处于抑制状态?我已经在设备上对此进行了测试,并且检查了电池电量是否不足。磁贴也固定在开始屏幕上。
这是我的 XML
string tileMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Tile>" +
"<wp:BackgroundImage>" + TextBoxBackgroundImage.Text + "</wp:BackgroundImage>" +
"<wp:Count>" + TextBoxCount.Text + "</wp:Count>" +
"<wp:Title>" + TextBoxTitle.Text + "</wp:Title>" +
"<wp:BackBackgroundImage>" + TextBoxBackBackgroundImage.Text + "</wp:BackBackgroundImage>" +
"<wp:BackTitle>" + TextBoxBackTitle.Text + "</wp:BackTitle>" +
"<wp:BackContent>" + TextBoxBackContent.Text + "</wp:BackContent>" +
"</wp:Tile> " +
"</wp:Notification>";