我正在为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 :(得分:0)
首先,从deviceToken中删除空字符。
其次,为你的fileName设置@符号;
string p12FileName = @“D:/ Worksapace / Coupzila / Certificates(3).p12”;
最后一步实现你的捕获,比如;
catch (Exception ex)
{
MessageBox.Show("There is an error from push notification. Details:\n" + ex);
}
对Apple很好。