【问题标题】:PushSharp WithCustomItem fails to sendPushSharp WithCustomItem 发送失败
【发布时间】:2013-05-29 02:16:34
【问题描述】:

我有 Android 和 Apple 推送通知与 PushSharp 一起使用,但我无法使用 Apple 通知发送自定义数据。

这发送完美:

push.QueueNotification(new AppleNotification()
                                   .ForDeviceToken(device.Identifier)
                                   .WithAlert(message)
                                   .WithSound("default")
                                   .WithBadge(7));

这根本不起作用:

push.QueueNotification(new AppleNotification()
                                   .ForDeviceToken(device.Identifier)
                                   .WithAlert(message)
                                   .WithSound("default")
                                   .WithCustomItem("incidentId", new[] { 1 })
                                   .WithBadge(7));

后者永远不会触发 NotificationSent、NotificationFailed、ServiceException 等,也永远不会到达手机。

使用 PushSharp 2.0.4.0 版

我尝试添加自定义数据的方式有问题吗?

【问题讨论】:

    标签: c# apple-push-notifications pushsharp


    【解决方案1】:

    1) 您是否在 ApplePushChannelSettings 中设置了生产环境(不是沙盒)?

    //Create our push services broker
    var push = new PushBroker();
    
    //Registering the Apple Service and sending an iOS Notification
    var appleCert = File.ReadAllBytes("YourCert.p12"));
    
    //isProduction - development or ad-hoc/release certificate
    push.RegisterAppleService(new ApplePushChannelSettings(isProduction, appleCert, "pwd"));
    

    2) 尝试使用

    WithCustomItem("incidentId", "1");
    

    3) 原因可能是声音文件名错误。我看到它没有扩展名。

    【讨论】:

    • 它是 2 号。文档说参数是(这个 AppleNotification n、字符串键、参数对象 [] 值)。我现在意识到 params 关键字可让您指定一个方法参数,该参数采用可变数量的参数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-28
    • 2014-06-09
    • 2015-01-02
    • 2014-07-05
    • 2020-07-28
    • 2020-10-15
    • 2011-08-21
    相关资源
    最近更新 更多