Home - growthbeat/Growthbeat-SDK-iOS-Starter-Project GitHub Wiki
Written in Japanese :jp:
APNs Provider API で通知送信
*.p12
形式のファイルから *.pem
形式ファイル作成
- Keychain を起動してナビゲーションにある login keychain に移動して Certificates でカテゴライズする。そして "Apple Development Push Services" のアコーディオンを開く。
- “Apple Development Push Services” を右クリックして Export “Apple Development Push Services ~″ を選択する。その後それを
apns-dev-cert.p12
(ファイル名は好きなもので大丈夫です。説明しやすいようにここではこの名前をしようしています) として保存する。パスワードは設定する必要はありません。 - 以下コマンドを実行してフォーマットを pem 形式にする:
$ openssl pkcs12 -in apns-dev-cert.p12 -out pushcert.pem -nodes -clcerts
デバイストークン取得
プロジェクトを実行すると以下のようにログにデバイストークンが出力されます:
2016-03-17 11:31:11.840 GrowthbeatStarterProject[680:427945] Device_Token -----> xxxxxxxxxxxxxxxxxxx
通知送信 (*送信設定は最低限です)
curl -s -o /dev/null -w "%{http_code}" \
-X POST \
-H "Content-Type: application/json" \
-H "apns-topic: com.sotayamashita.GrowthbeatStarterProject" \
-d '{"aps":{"alert":"Hello","sound":"default"}}' \
--cert </path/to/pem> \
--http2 https://api.development.push.apple.com:443/3/device/<device token>
Notification API で通知送信
Growth Push準備するもの
- Growthbeat Application ID
- Growthbeat Credential ID
通知送信 (*送信設定は最低限です)
curl -X POST \
-H "Accept: application/json" \
-d "applicationId=<your application id>" \ # Required String
-d "credentialId=<your credential id>" \ # Required String
-d "text=Hello" \ # Required String
https://api.growthpush.com/3/notifications
成功
{"jobId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}⏎
失敗
{"status":400,"message":"Invalid request."}