Introduction to Firebase Notifications

Introduction to Firebase Notifications

Introduction to Firebase Notifications

6dd0483f1353a4a359e92633cfd65c64?s=128

Daichi Furiya (Wasabeef)

June 10, 2016
Tweet

Transcript

  1. Firebase Notifications wasabeef shibuya.apk #8 at Google Japan

  2. About me Daichi Furiya wasabeef @wasabeef_jp CyberAgent, Inc.

  3. Firebase

  4. Firebase https://firebase.google.com/

  5. Analytics

  6. Crash Reporting

  7. Notifications

  8. Firebase Notifications

  9. Why?

  10. Create Android app

  11. Create Android app

  12. Create Android app

  13. Dependencies dependencies { // ... compile 'com.google.firebase:firebase-messaging:9.0.2' }

  14. FirebaseMessagingService public class MyMessagingService extends FirebaseMessagingService { @Override public void

    onMessageReceived(RemoteMessage msg) { sendNotification(msg.getNotification().getBody()); } private void sendNotification(String body) { // NotificationManager#notify } }
  15. FirebaseInstancedIdService public class MyIdService extends FirebaseInstanceIdService { @Override public void

    onTokenRefresh() { sendRegistrationToServer(refreshedToken); } private void sendRegistrationToServer(String token) { // send to your server } }
  16. Topic findViewById(R.id.button).setOnClickListener(v -> { FirebaseMessaging.getInstance() .subscribeToTopic("mytopic"); // FirebaseMessaging.getInstance() .unsubscribeFromTopic("mytopic"); });

  17. Compose message

  18. Status

  19. Conclusion

  20. Thank you. twitter.com/wasabeef_jp wasabeef.jp github.com/wasabeef