如何获取 Android 的 FCM 推送通知的注册令牌?

How to get registration token for FCM push notification for Android?

我正在使用 https://github.com/geeknam/python-gcm

构建推送通知服务

这需要 API_KEY 和设备的注册 ID 才能发送消息。

我在 console.developers.google.com 上创建了一个应用程序并获得了 API_KEY。 现在我不知道如何获得注册 ID。

是否有虚拟应用程序安装后会 return 注册 ID 或类似的东西?

I have created an app on console.developers.google.com and have got the API_KEY.

只有在 Firebase Console. API Keys (recently) generated in the Developer's Console would not work for GCM (and FCM). From the note in the docs (under Server Key) 中创建项目时,您才能获得有效的 服务器密钥 :

Starting from September 2016, you can create new server keys only in the Firebase Console using the Cloud Messaging tab of the Settings panel. Existing projects that need to create a new server key can be imported in the Firebase console without affecting their existing configuration.


Are there dummy app(s) on installation of which it will return registration ID or something like that?

您必须创建自己的虚拟应用程序,您必须在其中调用 getToken() 以生成注册令牌(也称为注册 ID)。见 FCM Quickstart in GitHub.