From e41f039f25088d20091072f708456755ba1e759f Mon Sep 17 00:00:00 2001 From: Greg Sakakihara Date: Tue, 26 Mar 2019 12:21:42 -0700 Subject: [PATCH] Make FirebaseMessagingServices not exported * Set FirebaseMessagingServices to exported="false" to explicitly prevent other apps from being able to send messages to it. * Fixed documentation to indicate to remove the Kotlin service intent filter for Java now that the Kotlin service is first in the manifest. --- messaging/README.md | 4 ++-- messaging/app/src/main/AndroidManifest.xml | 8 ++++++-- .../fcm/java/MyFirebaseMessagingService.java | 11 +++++++++++ .../fcm/kotlin/MyFirebaseMessagingService.kt | 11 ----------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/messaging/README.md b/messaging/README.md index 4179baef28..06172ab7d1 100644 --- a/messaging/README.md +++ b/messaging/README.md @@ -22,8 +22,8 @@ However, there can only be one service in each app that receives FCM messages. If multiple are declared in the Manifest then the first one will be chosen. -In order to make the Kotlin messaging sample functional, you must -remove the following from the `.java.MyFirebaseMessagingService` entry +In order to make the Java messaging sample functional, you must +remove the following from the `.kotlin.MyFirebaseMessagingService` entry in the `AndroidManifest.xml`: ``` diff --git a/messaging/app/src/main/AndroidManifest.xml b/messaging/app/src/main/AndroidManifest.xml index 52ba972cb1..d11b7cd95b 100644 --- a/messaging/app/src/main/AndroidManifest.xml +++ b/messaging/app/src/main/AndroidManifest.xml @@ -38,14 +38,18 @@ - + - + diff --git a/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/java/MyFirebaseMessagingService.java b/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/java/MyFirebaseMessagingService.java index 609ca3a5fb..7a78fc43d8 100644 --- a/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/java/MyFirebaseMessagingService.java +++ b/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/java/MyFirebaseMessagingService.java @@ -34,6 +34,17 @@ import androidx.work.OneTimeWorkRequest; import androidx.work.WorkManager; +/** + * NOTE: There can only be one service in each app that receives FCM messages. If multiple + * are declared in the Manifest then the first one will be chosen. + * + * In order to make this Java sample functional, you must remove the following from the Kotlin messaging + * service in the AndroidManifest.xml: + * + * + * + * + */ public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = "MyFirebaseMsgService"; diff --git a/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/kotlin/MyFirebaseMessagingService.kt b/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/kotlin/MyFirebaseMessagingService.kt index 589f57ea42..fda20d86f9 100644 --- a/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/kotlin/MyFirebaseMessagingService.kt +++ b/messaging/app/src/main/java/com/google/firebase/quickstart/fcm/kotlin/MyFirebaseMessagingService.kt @@ -15,17 +15,6 @@ import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.RemoteMessage import com.google.firebase.quickstart.fcm.R -/** - * NOTE: There can only be one service in each app that receives FCM messages. If multiple - * are declared in the Manifest then the first one will be chosen. - * - * In order to make this Kotlin sample functional, you must remove the following from the Java messaging - * service in the AndroidManifest.xml: - * - * - * - * - */ class MyFirebaseMessagingService : FirebaseMessagingService() { /**