Mercurial
comparison gara/android/firebase-cloud-messaging/app/src/main/java/com/example/myapplication/MyFirebaseMessagingService.java @ 47:829623189a57
[Gara] Android commit. Bazelfied it.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Sat, 13 Dec 2025 14:20:34 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 46:b9a40c633c93 | 47:829623189a57 |
|---|---|
| 1 package com.example.myapplication; | |
| 2 | |
| 3 import android.util.Log; | |
| 4 | |
| 5 import com.google.firebase.messaging.FirebaseMessagingService; | |
| 6 import com.google.firebase.messaging.RemoteMessage; | |
| 7 | |
| 8 public class MyFirebaseMessagingService extends FirebaseMessagingService { | |
| 9 @Override | |
| 10 public void onMessageReceived(RemoteMessage remoteMessage) { | |
| 11 | |
| 12 // TODO(developer): Handle FCM messages here. | |
| 13 // Not getting messages here? See why this may be: https://goo.gl/39bRNJ | |
| 14 Log.d("myapp", "From: " + remoteMessage.getFrom()); | |
| 15 | |
| 16 // Check if message contains a data payload. | |
| 17 if (remoteMessage.getData().size() > 0) { | |
| 18 Log.d("myapp", "Message data payload: " + remoteMessage.getData()); | |
| 19 | |
| 20 if (/* Check if data needs to be processed by long running job */ true) { | |
| 21 // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher. | |
| 22 //scheduleJob(); | |
| 23 } else { | |
| 24 // Handle message within 10 seconds | |
| 25 //handleNow(); | |
| 26 } | |
| 27 | |
| 28 } | |
| 29 | |
| 30 // Check if message contains a notification payload. | |
| 31 if (remoteMessage.getNotification() != null) { | |
| 32 Log.d("myapp", "Message Notification Body: " + remoteMessage.getNotification().getBody()); | |
| 33 } | |
| 34 | |
| 35 // Also if you intend on generating your own notifications as a result of a received FCM | |
| 36 // message, here is where that should be initiated. See sendNotification method below. | |
| 37 } | |
| 38 | |
| 39 } |