https://developers.google.com/oauthplayground/
https://blog.nearsoftjobs.com/spring-boot-oauth2-firebase-d8a4bf37ce15 https://qiita.com/mr-hisa-child/items/5ed2ae2fe4c86d4bb5c7
https://github.com/googleapis/google-auth-library-java#google-auth-library-oauth2-http
https://qiita.com/zaburo/items/801bd288cec47bd28764
rootでやるとnpmインストール時にパーミッションエラーがでるのでいかを付ける
https://firebase.google.com/docs/reference/js/firebase.auth.Auth.html#signinwithphonenumber
https://fir-ui-demo-84a6c.firebaseapp.com/
https://github.com/firebase/firebaseui-web-react/
相変わらずたどり着けないので、プロジェクトIDを調べて直アクセスが良い。
https://console.firebase.google.com/project/プロジェクトID/authentication/providers?hl=ja
https://firebase.google.com/docs/auth/admin/verify-id-tokens?hl=ja
https://firebase.googleblog.com/2017/11/whats-new-with-fcm-customizing-messages.html
アクセストークンの有効期間はリクエストしてから60分。
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"payloads\" at 'message.apns': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "message.apns",
"description": "Invalid JSON payload received. Unknown name \"payloads\" at 'message.apns': Cannot find field."
}
]
}
]
}
}
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
https://fcm.googleapis.com/v1/projects/プロジェクトID/messages:send
{
"message": {
"token": "トークン",
"name": "message name",
"notification": {
"body": "Test message 201711281530",
"title": "notification title"
}
},
"validate_only": true
}
https://console.developers.google.com/apis/api/fcm.googleapis.com/overview?project=tf-quickstart
curl -H "Content-type: application/json" -H "Authorization: Bearer トークン" -X POST -d '{ "validate_only": false, "message" : { "token": "test"}}' https://fcm.googleapis.com/v1/projects/[project-id]/messages:send
https://firebase.google.com/docs/cloud-messaging/auth-server?hl=ja
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
npm install -g firebase-tools firebase login とするとブラウザが立ち上がりログイン完了 新しくディレクトリを作り、その中でfirebase initすることで選択できる。。
firebase init firebase deploy
http://qiita.com/flatfisher/items/31f5c9e21ae56cccff8d http://inside.pixiv.net/entry/2016/12/03/190000
| FCM クライアント | AndroidやiOSやブラウザなどの通知を受け取るデバイス |
| サーバーキー | プロジェクトの設定→クラウドメッセージングで取得可能なAPIキー。間違っていると401である。 |
| 登録トークン | アプリを初めて起動すると、クライアント アプリのインスタンスの登録トークンが FCM SDK によって生成されます。間違っているとInvalidRegistrationが戻る |
| collapsible message | 後書きされても問題ないメッセージ。スポーツアプリのスコア情報通知は最新のものだけあれば良い。ただしデバイス単位で4つまでしか使えないのでたくさんの種類の通知をしたい場合には向いてない |
| non-collapsible message | 後書きされないメッセージ。100を超えると全部消えるのでその場合はその発生をhandlerで受けて再同期を実装する |
| priority | メッセージの優先度。通知はデフォルトでHighであり、スリープジも受信できる状況 |
| time_to_live | メッセージの生存期間。電話の着信通知などは短くして置かないと意味がない。 |
| SENDER_ID | 複数の通知元からのメッセージをまとめたい場合に使う |
送信予約完了してもあくまで送信予約がされたという状態。デバイスがオフラインモードだったりすると送信待ち状態となり、collapsibleの場合はこの時に上書きされる可能性がある。
| Android | 152バイト |
事前にサーバーキーが必要。
curl -H "Content-type: application/json" -H "Authorization:key=$KEY" -X POST -d '{"to": "ユニークなID","data": {"hello": "This is a Firebase Cloud Messaging Device Group Message!"}}' https://fcm.googleapis.com/fcm/send
curl -H "Content-type: application/json" -H "Authorization:key=$KEY" -X POST -d '{ "data": { "score": "5x1","time": "15:10"},"to" : "デバイストークンID"}' https://fcm.googleapis.com/fcm/send
curl -H "Content-type: application/json" -H "Authorization:key=$KEY" -X POST -d '{ "to": "/topics/foo-bar","data": { "message": "This is a Firebase Cloud Messaging Topic Message!"}}' https://fcm.googleapis.com/fcm/send
システム側が表出までハンドリングしてくれるもの。音やらIconやら設定可能
データは任意のものが設定できる代わりに、受信時に自分で処理を記載する必要がある。
https://github.com/firebase/quickstart-js/tree/master/messaging