2
是的,之前一直存在這方面的問題,但它們都可以追溯到2012年,甚至更早,使用不同版本的GCM。當收到消息時,GCM沒有喚醒設備
我在GCM 3.0,由谷歌這裏提供的指南以下內容:https://developers.google.com/cloud-messaging/android/client
的提供樣本清單如下:
<manifest package="com.example.gcm" ...>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<application ...>
<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.example.gcm" />
</intent-filter>
</receiver>
<service
android:name="com.example.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.example.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
</application>
</manifest>
相比之下,這裏是我的:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<permission android:name="com.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.myapp.permission.C2D_MESSAGE"/>
<application...
<service android:name=".service.NotificationListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
<service android:name=".service.GcmTokenListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceId"/>
</intent-filter>
</service>
<service android:name=".service.GcmRegistrationService"
android:exported="false"/>
<!-- Receivers -->
<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"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.myapp"/>
</intent-filter>
</receiver>
</manifest>
它看起來就像他們的,但我的手機不處理傳入的通知,直到手機醒來後。如果我向自己發送消息,它將保持休眠狀態,直到我解鎖手機,然後立即開始處理收到的消息。
有人碰到過這個嗎?