C#-苹果推送通知与APNS Sharp
作者:互联网
我将APNS Sharp库用于我的苹果推送通知.我从Here开始下载.我使用了APNS Sharp Library提供的示例测试程序,没有进行任何修改.
它只是在我将断点放在该行代码之前不会发送任何通知.
如果我把断点.我只是工作正常,是这种预期的行为,还是我做错了什么.而且我也没有任何例外.谢谢你的帮助.
这是代码
static void Main(string[] args)
{
bool sandbox = true;
string testDeviceToken = "Token";
string p12File = "apn_developer_identity.p12";
string p12FilePassword = "yourpassword";
int sleepBetweenNotifications = 15000;
string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File);
NotificationService service = new NotificationService(sandbox, p12Filename, p12FilePassword, 1);
service.SendRetries = 5;
service.ReconnectDelay = 5000; //5 seconds
service.Error += new NotificationService.OnError(service_Error);
service.NotificationTooLong += new NotificationService.OnNotificationTooLong(service_NotificationTooLong);
service.BadDeviceToken += new NotificationService.OnBadDeviceToken(service_BadDeviceToken);
service.NotificationFailed += new NotificationService.OnNotificationFailed(service_NotificationFailed);
service.NotificationSuccess += new NotificationService.OnNotificationSuccess(service_NotificationSuccess);
service.Connecting += new NotificationService.OnConnecting(service_Connecting);
service.Connected += new NotificationService.OnConnected(service_Connected);
service.Disconnected += new NotificationService.OnDisconnected(service_Disconnected);
Notification alertNotification = new Notification(testDeviceToken);
alertNotification.Payload.Alert.Body = "Testing {0}...";
alertNotification.Payload.Sound = "default";
alertNotification.Payload.Badge = i;
if (service.QueueNotification(alertNotification))
Console.WriteLine("Notification Queued!");
else
Console.WriteLine("Notification Failed to be Queued!");
Console.WriteLine("Cleaning Up...");
service.Close();// if i dont put a break point in here, it simply does not send any notification
service.Dispose();
}
我希望我的问题很清楚…
更新:我被困在这里.任何人都可以帮助我.
解决方法:
我发现了问题.这是APNS SHARP库线程工作流中的错误.
编辑:
我在排队所有通知后调用此方法.
喜欢
service.start();
这是方法
public void Send()
{
foreach (NotificationConnection conn in this.notificationConnections)
{
// Console.Write("Start Sending");
conn.start(P12File, P12FilePassword);
}
}
标签:push-notification,apple-push-notifications,apns-sharp,iphone,c 来源: https://codeday.me/bug/20191209/2098061.html