gpt4 book ai didi

c# - 带有 APNS sharp 的苹果推送通知

转载 作者:行者123 更新时间:2023-11-30 16:33:29 25 4
gpt4 key购买 nike

我将 APNS Sharp 库用于我的苹果推送通知。我已经从Here下载了.i使用APNS sharp library提供的示例测试程序,没有任何修改。
它只是不发送任何通知,直到我在该行代码处放置断点。如果我设置断点。我工作得很好。这是预期的行为还是我做错了什么。而且我也没有任何异常(exception)。谢谢你的帮助。这是代码

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 库线程工作流中的错误。

编辑:
我在排队所有通知后调用此方法。
喜欢
服务启动();
这是方法

     public void Send()
{
foreach (NotificationConnection conn in this.notificationConnections)
{
// Console.Write("Start Sending");
conn.start(P12File, P12FilePassword);
}
}

关于c# - 带有 APNS sharp 的苹果推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3162076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com