【问题标题】:How to capture background silent Push Notifications on UAPushNotificationDelegate for iOS?如何在 iOS 的 UAPushNotificationDelegate 上捕获后台静默推送通知?
【发布时间】:2018-08-22 13:42:34
【问题描述】:

我正在尝试在 iOS 应用程序上实现 静默推送通知,并且我遵循了适用于 iOS 的 Urban Airship Getting Started,但没有一个示例应用程序可以描述如何实现静默推送通知可以在 UAPushNotificationDelegate 上捕获。我创建了一个测试应用程序,它工作得很好。我目前正在收到简单的推送通知。

我一直在通过 CURLs 命令使用他们的 Push API 端点,它们运行良好。

我的目标是了解几件事:

  1. 如何创建自定义 Urban Airship 有效载荷以包含静默推送通知 ({"aps":{"content-available" : 1}})
  2. 如何创建自定义操作
  3. 如何实现自定义操作的注册
  4. 如何在 UAPushNotificationDelegate 的func receivedBackgroundNotification(_ notificationContent: UANotificationContent, completionHandler: @escaping (UIBackgroundFetchResult) -> Swift.Void)

我希望能够在我的应用程序上实现静默推送通知,我希望社区能帮助我这样做。以下是有关此事的参考 Apple 文档: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_updates_to_your_app_silently

以下是其他 UA 客户提出的一些同样问题的问题: https://support.urbanairship.com/hc/en-us/community/posts/115011296606-Differentiate-silent-notifications-from-normal-push-notification https://support.urbanairship.com/hc/en-us/community/posts/360010098392-Custom-actions-while-app-in-background https://support.urbanairship.com/hc/en-us/community/posts/360000003566-Background-notifications-working-on-some-devices-but-not-on-others

【问题讨论】:

    标签: ios push-notification urbanairship.com


    【解决方案1】:

    1) 已回复here

    2) 自定义操作:

    let customAction : UAAction = UAAction(block: {(args, completionHanlder) in
        // Do something with args
    
        completionHanlder(UAActionResult.empty())
    })
    

    3) 注册动作:

    UAirship.shared().actionRegistry.register(customAction, name: "custom_action_name")
    

    4) 实现委托并覆盖方法。如果您希望自定义操作运行,则需要在有效负载中将其定义为 app_defined 操作。

    【讨论】:

      猜你喜欢
      • 2018-12-05
      • 1970-01-01
      • 2021-05-14
      • 1970-01-01
      • 1970-01-01
      • 2015-08-25
      • 2015-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多