通知操作按钮未出现在 iOS 和 android 上使用 onesignal react-native-onesignal

Notification action buttons not appearing on iOS and android using one signal react-native-onsignal

我正在尝试发送带有操作按钮的通知。通知到达并完美运行 - 但是操作不会出现在 android (7.0) 或 iOS (11.2.1)

我将此正文连同 post 请求一起发送至 https://onesignal.com/api/v1/notifications |我什至尝试了 OS UI 仪表板工具,但没有任何效果。

{
    "app_id": "#########-#########-########",
    "heading": "OneSignal Web Push Notification",
    "contents": {
        "en": "Action buttons increase the ways your users can interact with your notification."
    },
    "data": {
        "notificationType": "news-feature"
    },
    "url": "https://example.com",
    "icon": "https://onesignal.com/images/notification_logo.png",
    "buttons": [
        {
            "action": "like-button",
            "title": "Like",
            "icon": "http://i.imgur.com/N8SN8ZS.png",
            "url": "https://example.com"
        },
        {
            "action": "read-more-button",
            "title": "Read more",
            "icon": "http://i.imgur.com/MIxJp1L.png",
            "url": "https://example.com"
        }
    ],
    "action": "like-button",
    "include_player_ids": [
        "######-###################-#####", //iOS ID
        "######-###################-#####", // android ID
    ]
}

关于如何解决或调试这个问题有什么想法或建议吗?

设置 OneSignalNotificationServiceExtension 以便按钮(以及图像等)出现在推送通知中解决了这个问题。

iOS Xcode 项目指南对此事有帮助:

https://github.com/Nightsd01/react-native-onesignal#add-notification-service-extension

一个小指针,用于跳过您必须 pod install 应用程序目标的 onesignal pod 的部分。只需安装 ServiceExtension pod。


对于 Android 更新 POST 请求中按钮对象的有效负载解决了问题。 { "app_id": "######-###################-#####", "heading": "OneSignal Web Push Notification", "contents": { "en": "Action buttons increase the ways your users can interact with your notification." }, "data": { "notificationType": "news-feature" }, "url": "https://example.com", "icon": "https://onesignal.com/images/notification_logo.png", "buttons":[ {"id": "id1", "text": "button1", "icon": "ic_launcher"}, {"id": "id2", "text": "button2", "icon": "ic_launcher"} ], "action": "like-button", "include_player_ids": [ "######-###################-#####", // iOS ID "######-###################-#####" // android ID ] }