2012-03-21 59 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中刪除空字符。

二,Put @ sign for your fileName;

string p12FileName = @「D:/ Worksapace/Coupzila/Certificates(3).p12」;

並在最後一步執行你的catch,就像;


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

與蘋果公司合作。