如何在iOS的UAPushNotificationDelegate上捕获背景静默推送通知?

问题描述 投票:0回答:1

我正在尝试在iOS应用程序上实现静态推送通知,我已经跟随Urban Airship Getting Started for iOS但是没有一个示例应用程序描绘了如何实现可以在UAPushNotificationDelegate上捕获的静默推送通知。我已经创建了一个测试应用程序,它运行得很好。我目前正在获得简单的推送通知。

我一直在使用他们的Push API端点通过CURLs命令,他们完美地工作。

我的目标是了解一些事情:

  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个回答
0
投票

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操作。

© www.soinside.com 2019 - 2024. All rights reserved.