Notifications API経由で、特定のユーザーに対してPush通知を送る方法
Notifications API経由で、特定のユーザーに対してPush通知を送るには、 下記の様な手順でPushを配信する必要があります。
1. 予めデバイスに対してユニークなIDをタグ付けする
iOS GrowthbeatSDK を使う場合
[GrowthPush setTag:@"userId" value:@"123"];
Android GrowthbeatSDKを使う場合
GrowthPush.getInstance().setTag("userId", "123");
Tags API を使う場合
curl -X POST \
-H 'Accept: application/json'
-d 'applicationId=${APPLICATION_ID}' \
-d 'credentialId=${CREDENTIAL_ID}' \
-d 'clientId=${GROWTHBEAT_CLIENT_ID}' \
-d 'tagId=0' \
-d 'value=value' \
https://api.growthpush.com/4/tag_clients
{
"tagId": 0,
"clientId": "GROWTHBEA_CLIENT_ID",
"value": "VALUE"
}
| Name | Type | Required | Default | Note |
|---|---|---|---|---|
| applicationId | String | ture | Growthbeat applicationId | |
| credentialId | String | true | Growthbeat credentialId | |
| clientId |
String | true | ||
| tagId |
Number | true | ||
| value | String | false |
2. Notifications APIを使用して、上記でタグ付けしたIDに対してセグメント配信する
下記APIで、タグ名「userId」の値が「123,456」のデバイスに対して、配信ができます。
※タグ名「userId」のtagIdを${TAG_ID}とする。tagIdは 管理画面上でご確認いただけます。
curl -X POST \
-H 'Accept: application/json' \
-d 'applicationId=${APPLICATION_ID}' \
-d 'credentialId=${CREDENTIAL_ID}' \
-d 'query={"type":"or","conditions":[{"type":"tag","tagId":${TAG_ID},"operator":"equal","value":123},{"type":"tag","tagId":${TAG_ID},"operator":"equal","value":456}]}' \
-d 'text=APIによる通知です。' \
-d 'sound=true' \
-d 'badge=true' \
-d 'extra={}' \
-d 'attachNotificationId=false' \
-d 'duration=10000' \
https://api.growthpush.com/3/notifications
| Name | Type | Required | Default | Note |
|---|---|---|---|---|
| applicationId | String | ture | Growthbeat applicationId | |
| credentialId | String | true | Growthbeat credentialId | |
| query | String | false | ||
| text | String | true | ||
| sound | boolean | false | false | |
| badge | boolean | false | false | |
| extra | boolean | false | ペイロードに任意のパラメータを追加※JSON形式で指定します。ex. {"url":"https://growthpush.com"} | |
| attachNotificationId | boolean | false | false | 指定するとペイロードに "growthpush":{"notificationId":xxxxx} という形式で、通知IDが含まれます。 |
| duration | Long | false | 配信時刻からこの時間以上の時間が経過したpushは配信されずに破棄されます。ミリ秒で指定してください。 |
APIの詳細については、 APIリファレンス をご参考ください。