2012-03-21 14 views
0

私はiPhoneのプッシュ通知に取り組んでいます。私はボタンクリックで通知を送信していますが、iPhone開発者はアラートメッセージを受信して​​いません。誰も私を助けることができますか? これは私の方法である -プッシュ通知、iPhoneで警告メッセージが受信されない

protected void btnPush_Click(object sender, EventArgs e) 
{ 
    string devicetoken = "bhsdse78 d52c6a34 273de5f7 27947945 24736e36 33d93a6c 3147a416 434995eb"; 
    try 
    { 
     if (devicetoken != "") 
     { 
      //lblError.Visible = false; 
      string p12FileName = "D:/Worksapace/Coupzila/Certificates(3).p12"; // change this to reflect your own certificate 
      string p12Password = "seas"; // change this 
      bool sandBox = true; 
      int numConnections = 1; // you can change the number of connections here 
      var notificationService = new NotificationService(sandBox, p12FileName, p12Password, numConnections); 
      var deviceToken = devicetoken; // put in your device token here 
      var notification = new Notification(deviceToken); 

      notification.Payload.Alert.Body = "Hi this is push notification test message."; 
      notification.Payload.Sound = "default"; 
      notification.Payload.Badge = 1; 
      notification.Payload.HideActionButton = true; 
      if (notificationService.QueueNotification(notification)) 
      { } 
      else 
      { } 
      // This ensures any queued notifications get sent befor the connections are closed 
      notificationService.Close(); 
      notificationService.Dispose(); 

     } 
     else 
     { 
      //lblError.Visible = true; 
     } 

    } 
    catch (Exception ex) 
    { 

    } 
} 

このメソッドが正常に実行されているが、私のコードではiPhone、Whtz問題に関する通知が届かないのですか? お世話になります。ありがとうございます。

答えて

0

まず、deviceTokenから空の文字を削除してください。

第2に、あなたのfileNameに@記号を付ける;

文字列p12FileName = @ "D:/ Worksapace/Coupzila/Certificates(3).p12";

最後のステップでは、次のようにキャッチを実装します。


    catch (Exception ex) 
    { 
     MessageBox.Show("There is an error from push notification. Details:\n" + ex); 
    } 

アップルでいいですね。

関連する問題