OneSignal推送通知到所有细分市场
我正在尝试从管理设备向所有设备发送推送通知(段:"ALL").我似乎无法使其与此代码一起使用.
I am trying to send push notification from the admin device, to all devices (segment:"ALL"). I can't seem to get it to work with this code.
let data = [
"contents": ["en": "\(message)"],
"included_segments": ["All"],
"excluded_segments": ["None"],
"ios_badgeType": "Increase",
"ios_badgeCount": 1
]
OneSignal.defaultClient().postNotification(data)
无"段存在,其中有0个用户. 全部"具有所有活动用户.
The "None" segment exists and has 0 users in it. "All" has all active users.
发布通知时出现错误
错误:创建通知失败
ERROR: Create notification failed
这确实可以正常工作:
let data = [
"contents": ["en": "\(message)"],
"include_player_ids":["20a32b7a-4254-4e03-a24c-13fe8bd91fff"],
"ios_badgeType": "Increase",
"ios_badgeCount": 1
]
OneSignal.defaultClient().postNotification(data)
您只能使用postNotification
中的include_player_ids
,因为其他定位参数(例如included_segments
)需要您的OneSignal App REST API密钥.
You can only use include_player_ids
from postNotification
as other targeting parameters like included_segments
require your OneSignal App REST API key.
如果您需要定位所有用户,则应首先从您的应用调用服务器,在此您可以安全地使用
If you need to target all users you should first make a call to your server from your app where you can safely use the create notification REST API POST call.