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'"
What’s happening?
-
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.
-
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
Related gist page:
https://gist.github.com/tolpp/45801406e13ed7c88fb768352bb39f9b
onMessageReceived
under the FirebaseMessagingService
. When user taps notification remoteMessage.getData().get("extra1")
should be return "65"
.Related gist page:
https://gist.github.com/tolpp/45801406e13ed7c88fb768352bb39f9b