OneSignal推送通知到所有细分市场 [英] OneSignal push notification to all segments

查看:134
本文介绍了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.

这篇关于OneSignal推送通知到所有细分市场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆