Flutter Firebase apiKey、appId、messagingSenderId 和 projectId
Flutter Firebase apiKey, appId, messagingSenderId and projectId
我需要使用 firebase_messaging
将消息从我的后端发送到我的 flutter apk。
初始化firebase时,这些是FirebaseOptions
中必不可少的4个键
apiKey : Is this the Server Key found in FCM?
appId : Where can I find this key?
messagingSenderId : Sender ID FCM
projectId : Where can I find this?
此外,为了让我向单个用户发送消息。我需要告诉 Firebase 我是谁? 请问我应该使用哪个ID?
感谢
当您向 firebase 注册时,您将获得推送通知令牌。此令牌用于向安装该应用程序的设备发送通知。
假设您已经在 flutter 中初始化了 firebase 应用程序,并且在您的应用程序中添加了 google-services.json
。您可以通过以下方式获取您的推送通知令牌:
messaging = FirebaseMessaging.instance;
messaging.getToken().then((value){
print(value); //this is the push notification token
});
您还可以测试您是否能够从 firebase 控制台接收应用程序上的通知。您可以在 firebase 控制台的 Compose notification
部分下向应用程序发送通知。它只需要您从应用程序获得的通知令牌。
我需要使用 firebase_messaging
将消息从我的后端发送到我的 flutter apk。
初始化firebase时,这些是FirebaseOptions
apiKey : Is this the Server Key found in FCM?
appId : Where can I find this key?
messagingSenderId : Sender ID FCM
projectId : Where can I find this?
此外,为了让我向单个用户发送消息。我需要告诉 Firebase 我是谁? 请问我应该使用哪个ID?
感谢
当您向 firebase 注册时,您将获得推送通知令牌。此令牌用于向安装该应用程序的设备发送通知。
假设您已经在 flutter 中初始化了 firebase 应用程序,并且在您的应用程序中添加了 google-services.json
。您可以通过以下方式获取您的推送通知令牌:
messaging = FirebaseMessaging.instance;
messaging.getToken().then((value){
print(value); //this is the push notification token
});
您还可以测试您是否能够从 firebase 控制台接收应用程序上的通知。您可以在 firebase 控制台的 Compose notification
部分下向应用程序发送通知。它只需要您从应用程序获得的通知令牌。