2013-07-10 4 views
2

MSDN에서 Windows Phone 8에 클라우드 알림을 보내려는 샘플을 다운로드했습니다. 그러나 나는 항상 null로 채널 URI를 가져오고 있습니까? 에뮬레이터 8에서 실행 중입니다.푸시 알림 Windows Phone 8 MSDN의 샘플

의견이 있습니까?

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.enter code here 
      System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString()); 
      MessageBox.Show(String.Format("Channel Uri is {0}", 
       pushChannel.ChannelUri.ToString())); 

     } 
    } 

위의 코드에서 난 항상 당신이 에뮬레이터를 사용하기 때문에 항상 null이됩니다

+0

일부 코드는 도움이됩니다. –

+0

위의 코드를 참조하십시오. – CodeR

답변

0

"널 (null)"로 채널 열린 우리당을 얻고, 로컬 컴퓨터를 사용해보십시오.

+0

나는 장치 사용에도 불구하고 여전히 null로 나타납니다.이 문제에 대해 설명해 주시겠습니까? 내가 너무 인터넷 액세스와 함께 잠금 해제 된 전화에서 그것을 시도했다. 내가 처음 응용 프로그램을 실행할 때 그것은 채널 URI가 null 인 것처럼 충돌 두 번째 시간을 실행하지 않는다 – CodeR

+0

어쩌면이 http : //go4answers.webhost4life 도움이 될 것입니다. co.kr/Example/push-notification-channel-uri-null-57261.aspx – Grievoushead

+1

링크를 제공해 주셔서 감사합니다.하지만 이미 시도해 보았습니다. 이 앱을 상점에 연결해야합니까? 또는 우리는 서버에 질의하기 위해 어떤 유형의 인증서가 필요합니까? – CodeR

0

그래서 내 네트워크 환경에 문제가있었습니다. 도메인이 아닌 PC에서 시도해 보았지만 정상적으로 작동했습니다. 의견 및 시간을 내 주셔서 감사합니다

+0

안녕하세요 CodeR, 적절한 솔루션을 공유하시기 바랍니다, 나는 또한 WP8 장치 (Nokia Lumia 520) 시도했지만 채널 uri 항상 NULL을 같은 문제에 직면하고 있습니다. Infect 내 휴대 전화 장치뿐만 아니라 데이터 연결 네트워크에 연결되어 있습니다. – WmDev

+0

도메인 PC에 있습니까? – CodeR

+0

방화벽 설정을 확인하십시오 – CodeR