几天前,我发送推送通知的代码停止工作:(
程序开始挂在最后一行apnsBroker.Stop();上
我使用NuGet包PushSharp.Core https://github.com/mitch-tofi/PushSharp.Core
2021-04-27 12:29:58.ПП [DEBUG] Scaled Changed to: 1
2021-04-27 12:29:58.ПП [INFO] Stopping: Waiting on Tasks
2021-04-27 12:29:58.ПП [INFO] Waiting on all tasks 1
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Sending Batch ID=1, Count=1
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Connecting (Batch ID=1)
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Connected (Batch ID=1)
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Sent Batch, waiting for possible response...
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Data Available...
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Finished Read.
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Received 0 bytes response...
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Server Closed Connection...
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Disconnecting (Batch ID=1)
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Disconnected (Batch ID=1)
2021-04-27 12:29:59.ПП [INFO] APNS-Client[1]: Done Reading for Batch ID=1, reseting batch timer...
我的代码如下:
public void sendTestNotification()
{
..........
// Start the broker
apnsBroker.Start();
// Queue a notification to send
var aps = new Aps();
aps.aps = new Aps2() { alert = "TestForYou", badge = 0 };
var json = JsonConvert.SerializeObject(aps);
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = "MY VALID TOKEN",
Payload = JObject.Parse(json)
});
//}
// Stop the broker, wait for it to finish
// This isn't done after every message, but after you're
// done with the broker
apnsBroker.Stop();
Console.WriteLine($"APNSBroker stopped");
}
完整代码在这里,https://github.com/emakhankov/ProblemApplePush/tree/main
发布于 2021-06-08 20:27:13
https://stackoverflow.com/questions/67280812
复制相似问题