Skip to content

Commit

Permalink
Merge branch 'web_push'
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu committed Jun 4, 2019
2 parents 790bab6 + ee64ba1 commit 2cbae9a
Show file tree
Hide file tree
Showing 27 changed files with 659 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ root = true

[*.js]
indent_style = space
indent_size = 4
indent_size = 2
44 changes: 44 additions & 0 deletions doc/PUSH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 設定

![Firebase console](./fcm.jpg)

### messagingSenderId

firebaseのコンソールから送信者ID(Sender ID)を取得、
public/firebase-messaging-sw.js のmessagingSenderIdを設定するに設定
(公開してよいID)

### messageKey

firebaseのコンソールで、web pushの証明書を追加し、公開鍵を設定取得して
src/firebase/firebase.jsのmessageKeyに設定
(公開しても良い鍵)

### server key
firebaseのコンソールでサーバーキーを取得。メモしておく。設定する必要はない。pushを送るときに使う。
これは公開しては駄目なキー。

### client key
デプロイして、ブラウザでアクセスする。
設定が成功していれば、通知許可するか聞かれるので許可する。
ブラウザのデバッグコンソールでclient keyを確認してコピー。メモる。
(公開しないほうがよいkey)

![Client key on debug console](./fcm_client_key.jpg)

# push

doc/以下で以下のコマンドでpushする

```
SERVERKEY="{server_key}" CLIENTKEY="{client_key}" bash push.sh
```

成功していれば通知が届く

![Push on desktop](./fcm_desktop.jpg)





Binary file added doc/fcm.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/fcm_client_key.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/fcm_desktop.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions doc/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
curl -X POST -H "Authorization: key=${SERVERKEY}" -H "Content-Type: application/json" -d "{
\"to\": \"${CLIENTKEY}\",
\"notification\": {
\"title\": \"FCM Message\",
\"body\": \"Hello Singularity Society\",
\"icon\": \"./img/icons/android-chrome-192x192.png\"
}
}" https://fcm.googleapis.com/fcm/send
Loading

0 comments on commit 2cbae9a

Please sign in to comment.