使用adb shell命令接收推送通知 [英] Receiving push notifications using adb shell command
本文介绍了使用adb shell命令接收推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下adb shell命令在设备上接收推送通知:
I am trying to receive push notifications on my device, using the below adb shell command:
adb shell am broadcast -c com.xxxx.android -a com.google.android.c2dm.intent.RECEIVE -e data "Data"
但是我没有收到任何推送消息或错误。
But I am not receiving any push messages or errors.
这是我得到的输出:
Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.myapp] (has extras) } Broadcast completed: result=0
推荐答案
以下是 adb broadcast 命令的基本用法:
Here is the basic use of 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...]]
在 AndroidManifest.xml 中找到 RECEIVER_NAME :
<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>
示例命令:
adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -n <YOUR_PACKAGE_NAME>/<YOUR_RECEIVER_NAME> --es "<EXTRA_KEY>" "<EXTRA_VALUE>"
这篇关于使用adb shell命令接收推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文