ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
FCM
Device to Device
Takuma@Android Study Group
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
Agenda
? FCM InstanceID token
? Firebase Database
? Firebase RemoteCon?g
? GCM Parameter
? Live Debugging & Demo
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.
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.
FCM InstanceID Token
Firebase Database
? Rule
? No setting, database will return ¡°Permission denied.¡±
? Code in FirebaseManager.java
Firebase Database
Firebase RemoteCon?g
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
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
Post Format
https://?rebase.google.com/docs/cloud-messaging/send-message
Receive Messages
? FirebaseMessagingService:onMessageReceived
Question?
Live Debugging & Demo
Extending
? Awesome Chat (https://github.com/TADSG/my-awesome-chat)
? Gitbook (https://www.gitbook.com/book/cateyeslin/
myawesomechat/details)
Thanks

More Related Content

Firebase Cloud Messaging Device to Device

  • 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
  • 3. Agenda ? FCM InstanceID token ? Firebase Database ? Firebase RemoteCon?g ? GCM Parameter ? Live Debugging & Demo
  • 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.
  • 7. Firebase Database ? Rule ? No setting, database will return ¡°Permission denied.¡± ? Code in FirebaseManager.java
  • 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
  • 16. Extending ? Awesome Chat (https://github.com/TADSG/my-awesome-chat) ? Gitbook (https://www.gitbook.com/book/cateyeslin/ myawesomechat/details)