【问题标题】:Sending Apple Push Notification via PushSharp.Core stopped working通过 PushSharp.Core 发送 Apple 推送通知停止工作
【发布时间】:2021-04-27 09:53:50
【问题描述】:

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

程序开始挂在最后一行 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

【问题讨论】:

    标签: c# .net-core apple-push-notifications


    【解决方案1】:

    我们目前正在研究同样的问题,苹果似乎正在禁用旧的二进制接口,这会推动尖锐的使用。

    https://developer.apple.com/news/?id=c88acm2b

    pushsharp 已在路线图上支持新界面,但尚未完成。

    发现这个库似乎很容易用作解决方案。希望这会有所帮助。

    https://github.com/alexalok/dotAPNS

    【讨论】:

    【解决方案2】:

    您可以使用https://github.com/fseydayucel/PushSharpHttpTwo

    如果将此用于 MDM,请编辑行:https://github.com/fseydayucel/PushSharpHttpTwo/blob/7f15393ea3d7b9528854d950bcc606e4c95097aa/PushSharp.Apple/ApnsHttp2Configuration.cs#L83

    阅读if (!commonName.Contains ("ASPS:"))

    然后重新编译。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多