首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >通过PushSharp.Core发送苹果推送通知停止工作

通过PushSharp.Core发送苹果推送通知停止工作
EN

Stack Overflow用户
提问于 2021-04-27 09:53:50
回答 2查看 1.5K关注 0票数 2

几天前,我发送推送通知的代码停止工作:(

程序开始挂在最后一行apnsBroker.Stop();

我使用NuGet包PushSharp.Core https://github.com/mitch-tofi/PushSharp.Core

代码语言:javascript
运行
复制
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...

我的代码如下:

代码语言:javascript
运行
复制
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

EN

Stack Overflow用户

发布于 2021-06-08 20:27:13

票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67280812

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档