推送通知,iPhone上未收到提醒消息
问题描述:
我正在为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问题? 帮帮我,在此先感谢
答
首先,从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);
}
与苹果公司合作。