在Android上模拟GCM推送通知

在Android上模拟GCM推送通知,android,google-cloud-messaging,Android,Google Cloud Messaging,我正在尝试使用ADB在我的Android应用程序上模拟GCM推送通知: adb shell am broadcast -c com.MYAPPNAME -a com.google.android.c2dm.intent.RECEIVE -e data "SomeData" 据我所知,我得到了积极的结果: Broadcasting: Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.MYAPPNAME] (has extr

我正在尝试使用ADB在我的Android应用程序上模拟GCM推送通知:

adb shell am broadcast -c com.MYAPPNAME  -a com.google.android.c2dm.intent.RECEIVE -e data "SomeData"
据我所知,我得到了积极的结果:

Broadcasting: Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.MYAPPNAME] (has extras) }
Broadcast completed: result=-1
但不幸的是,我的应用程序在我的GCMListener上没有收到通知

相关舱单:

    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<permission
    android:name="com.sears.devicelab.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.sears.devicelab.permission.C2D_MESSAGE" />

.... some more xml ....

     <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        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="com.MYAPP" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        </intent-filter>
    </receiver>

    <service
        android:name=".common.gcm.AppGcmListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>
    <service
        android:name=".common.gcm.GcmInstanceIDListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>
    <service
        android:name=".common.gcm.GcmRegistrationIntentService"
        android:exported="false" >
    </service>

为了测试接收推送通知,我使用

您可以使用
curl
httpie

http POST 'https://gcm-http.googleapis.com/gcm/send' 'Content-Type:application/json' 'Authorization:key=<your_API_key>' to='<your_device_token>'
httppost'https://gcm-http.googleapis.com/gcm/send“”内容类型:应用程序/json“”授权:密钥=”到=“”
http POST 'https://gcm-http.googleapis.com/gcm/send' 'Content-Type:application/json' 'Authorization:key=<your_API_key>' to='<your_device_token>'