如何在生产中成功发送APNS的推送通知

时间:2013-06-07 02:24:44

标签: iphone asp.net xcode

如何在生产中成功发送APNS的推送通知

当我在开发中使用时,它是有效的。

但在生产中使用,似乎有误。

我的应用程序在App Store中,因此p12文件正在生产中。

我的服务器端是asp.net。

asp.net代码:

//key

//True if you are using sandbox certificate, or false if using production

bool sandbox = false;
        string p12File = "InspirePass.p12";
        string p12Filename = System.IO.Path.Combine(MapPath("~"), p12File);
        string p12FilePassword = "xxxxxxxx";
        NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1);

//send
foreach (DataRow eachUserRow in userTable.Rows)
            {
                //Create a new notification to send
                if (eachUserRow["pushStatus"].ToString() == "N")
                {   //////no repeat
                    Notification alertNotification = new Notification(eachUserRow["device_token"].ToString());
                    alertNotification.Payload.Alert.Body = eachUserRow["menuMessage"].ToString() + "(" + eachUserRow["menuTitle"].ToString() + ")";
                    alertNotification.Payload.Sound = "default";
                    alertNotification.Payload.Badge = selectEventPush_IOS.Rows.Count + selectSignPush_IOS.Rows.Count;

                    // alertNotification.Payload. = 1;                       

                    string[] items = new string[1];
                    string[] items2 = new string[1];
                    if (userTable.Rows.Count > 0)
                    {
                        items[0] = Convert.ToString(selectEventPush_IOS.Rows.Count); 
                        items2[0] = Convert.ToString(selectSignPush_IOS.Rows.Count);
                    }
                    alertNotification.Payload.CustomItems.Add("items2", items2);
                    alertNotification.Payload.CustomItems.Add("items", items);
                    //Queue the notification to be sent
                    if (service.QueueNotification(alertNotification))
                        result = 1;
                    else
                        result = -1;
                    ///////change chat_document/pushStatus=Y
                    string Identifier = "";
                    Identifier = eachUserRow["Identifier"].ToString();
                    DataRow yespushuser = DBiphone.UpdatedPushStatus(Identifier);
                }
            }//end if
            service.Close();
            service.Dispose();
            Response.Write(result.ToString());

0 个答案:

没有答案
相关问题