원시 알림을 사용하는 Windows Phone 8 앱을 개발하고 있습니다. 이를 위해 샘플 "How to send and receive raw notifications for Windows Phone 8"을 따르고 있습니다. WP8에서 알림을 푸시하면 항상 새 URI가 생성됩니다.
나는 샘플로 정확하게 코딩 : 나는 장치의 코드를 실행 한 후public MainPage()
{
/// Holds the push channel that is created or found.
HttpNotificationChannel pushChannel;
// The name of our push channel.
string channelName = "RawSampleChannel";
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.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(PushChannel_HttpNotificationReceived);
pushChannel.Open();
}
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);
pushChannel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(PushChannel_HttpNotificationReceived);
// 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()));
}
}
, 나는 앱이 다른 URI 내가 그것을 실행할 때마다 생성되는 것을 보았다.
나는 HttpNotificationChannel.Find (channelName)이 항상 null을 반환한다는 것을 깨달았습니다. (그 이유는 앱이 항상 새로운 URI를 생성하기 때문입니다.)
나는 이미 this을 읽었지만 여전히 도움이되지 못했습니다.
는 그래서, 내 질문은 :
- 해서는 안 HttpNotificationChannel.Find (CHANNELNAME) 반환 응용 프로그램이 이미 채널을 생성 한 경우 '널'다른 뭔가?
내가 도움이 될만한 것을 놓친 경우 말해주십시오.