我正在尝试使用操作按钮发送通知。通知到达并完美运行 - 但是在Android(7.0)或iOS(11.2.1)
上都没有出现任何操作我将这个帖子请求发送到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
]
}
有关如何解决或调试此问题的任何想法或建议?
答案 0 :(得分:1)
设置OneSignalNotificationServiceExtension以便在推送通知中显示按钮(以及图像等)来解决问题。
iOS Xcode项目指南对此有帮助:
https://github.com/Nightsd01/react-native-onesignal#add-notification-service-extension
一个小指针,用于跳过必须{app}目标的信号窗格pod install
的部分。只需安装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
]
}