Receive push notifications using adb shell command

I am trying to get push notifications on my device using the following adb shell command:

adb shell am broadcast -c com.xxxx.android -a com.google.android.c2dm.intent.RECEIVE -e data "Data" 

But I do not receive any push messages or errors.

This is the result I get:

 Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.myapp] (has extras) } Broadcast completed: result=0 
+5
source share
2 answers

Here is the main use of the adb broadcast command:

 adb shell am broadcast -a <INTENT_NAME> -n <PACKAGE_NAME>/<RECEIVER_NAME> [--ei <EXTRA_KEY> <EXTRA_INT_VALUE>] [--es <EXTRA_KEY> <EXTRA_STRING_VALUE>] [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>] [--el <EXTRA_KEY> <EXTRA_LONG_VALUE>] [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE>] [--eu <EXTRA_KEY> <EXTRA_URI_VALUE>] [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>] [--e*a <EXTRA_KEY> <EXTRA_*_VALUE>[,<EXTRA_*_VALUE...]] 

And you can find RECEIVER_NAME in AndroidManifest.xml :

 <receiver android:name="foo.bar.SomeBroadcastReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="xyz.abc" /> </intent-filter> </receiver> 

Command example:

 adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -n <YOUR_PACKAGE_NAME>/<YOUR_RECEIVER_NAME> --es "<EXTRA_KEY>" "<EXTRA_VALUE>" 
+8
source

Usage should use the -n switch instead of -c .

The -c switch is the category switch.

  [-c <CATEGORY> [-c <CATEGORY>] ...] 

Use command:

  adb shell am broadcast -m com.myapp -a com.google.android.c2dm.intent.RECEIVE -e key "data" 
0
source

Source: https://habr.com/ru/post/1205757/


All Articles