我正在尝试在iOS应用程序上实现静态推送通知,我已经跟随Urban Airship Getting Started for iOS但是没有一个示例应用程序描绘了如何实现可以在UAPushNotificationDelegate上捕获的静默推送通知。我已经创建了一个测试应用程序,它运行得很好。我目前正在获得简单的推送通知。
我一直在使用他们的Push API端点通过CURLs命令,他们完美地工作。
我的目标是了解一些事情:
({"aps":{"content-available" : 1}})
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
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
操作。