This document summarizes how to use Firebase Cloud Messaging (FCM) to send messages between Android devices without an FCM connection server. It discusses obtaining an FCM instance ID token, using the Firebase database and RemoteConfig, including the server key and message format in FCM requests, and handling received messages with FirebaseMessagingService. The presenter provides code examples and demos how to extend this approach for applications like chat messaging.
2. Takuma Lee@Android Study Group
vmgsahm1@gmail.com
Individual App Developer@MangaChat
Today¡¯s source code
https://github.com/TakumaMochizuki/FcmD2D
Download APK: http://bit.ly/2d75nfx
Licensed under the Charlie Tsai
4. FCM InstanceID Token
? Access the device registration token
? On initial startup of your app, the FCM SDK generates a registration token
for the client app instance.
? If you want to target single devices or create device groups, you'll need to
access this token by extending FirebaseInstanceIdService.
5. FCM InstanceID Token
? The registration token may change when
? The app deletes Instance ID
? The app is restored on a new device
? The user uninstalls/reinstall the app
? The user clears app data.
10. GCM Parameter
A message request is made of 2 parts: HTTP header and HTTP body.
The HTTP header must contain the following headers:
? Server Key
? Header -> Authorization: key=YOUR_SERVER_KEY (Authorization, key=Azlxxxxxx¡ic)
? Header -> Content-Type: application/json (for JSON)
? Header -> application/x-www-form-urlencoded;charset=UTF-8 (for plain text.)
? Request Url
? https://fcm.googleapis.com/fcm/send
https://developers.google.com/cloud-messaging/http
11. Server Key
Step #1: Log into https://cloud.google.com/console with your Google account
Step #2: In the navigation on the left, go into "APIs & auth > APIs"
Step #3: Find "Google Cloud Messaging for Android" and open this service.
Step #4: In the navigation on the left, go into "APIs & auth > Credentials
Step #5: You can see the Server key (auto created by google service)
Step #6: Copy your key