Requirements:
-
Device should be a rooted (simulator’s are rooted by default)
-
adbd should be started as root. (Rub command:
adb root
)
Now, send local push message using command:
adb shell am broadcast \
-n com.your.app/com.google.firebase.iid.FirebaseInstanceIdReceiver \
-a "com.google.android.c2dm.intent.RECEIVE" \
--es "extra1" "65" \
--es "guid" "1f400184-9215-479c-b19a-a9cd9a1d9dc9" \
--es "extra3" "VALUE" \
--es "extra4" "'Long string with spaces'"
-
Simply, using adb we are broadcasting message with parameters.
-
adb shell am broadcast
command that broadcasts. -
-n
parameter for definecomponent
(see IntentSpec@ADB Documentation) -
We are broadcasting for
com.google.firebase.iid.FirebaseInstanceIdReceiver
, because we are using Firebase Messaging Service -
We are sending action
-a com.google.android.c2dm.intent.RECEIVE
because FirebaseInstanceIdReceiver defines this inAndroidManifest.xml
file.-
Also, this is why we need to be root. This action requires Signature level permission.
-
-
We are adding extras with
--es
parameter.
Now, we can get data in onMessageReceived
under the FirebaseMessagingService
. When user taps notification remoteMessage.getData().get("extra1")
should be return "65"
.
Thanks for the gist. For others who try this and it doesn't work, it might be because you do not have the below in your app's AndroidManifest. Feel free to add (but remove it before committing) in order to test. This is the other end of what the broadcast is plugging into.