8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

firebase(FCM)で購読したトピックの一覧を取得する

Posted at

2020/4/27時点での情報です

FCMのトピックメッセージングではクライアントから簡単にトピックの購読、購読解除が可能です。
しかし、購読したトピックの一覧を取得する方法は少し面倒です。
具体的には以下のAPIを使用します。

URL:
https://iid.googleapis.com/iid/info/$IID_TOKEN?details=true
HEADER:
Authorization: key=$SERVER_KEY

IID_TOKE: クライアントで取得できるトークン
SERVER_KEY: firebaseのコンソールから確認できるキー

上記のAPIにリクエストを送ると購読しているトピックの一覧を取得することができます。
APIがあるなら簡単では?と思うかもしれませんが問題なのはSERVER_KEYです。
SERVER_KEYが分かると任意のtopicにプッシュ通知を送ることができます。
要するにSERVER_KEYをクライアントに埋め込んでリリースしてしまうと悪意のあるユーザーからプッシュ通知送り放題になってしまう可能性があります。
安全にするためには必ずwebサーバーを用意し、webサーバー経由で購読しているトピック一覧を取得しなければならず面倒です。

明らかに面倒なのでFCM SDKから取得できるようにしてほしいというissueが立っています。
FR: Add API for checking subscription status of a given topic #225

2017年から存在しているissueで未だに解決してなくてもう無理だと思ってましたが最近になって以下のコメントが付いています。

Thanks for bring this up to our attention, please upvote at the top, and I will bring this to our PM again to see if priority shifts.

この機能が必要だと思った方はぜひ:thumbsup:しておきましょう。

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?