问题
I got a working example of a third party server to send push notifications to the device which is perfectly working in the Android emulators I use. As soon as I try to use it on my real device (Samsung Galaxy S) I don't receive my notifications anymore, even tough I reregister the device at the google server (as I use the same gmail account). I basically have no clue where to start looking as Logcat is not giving me any interesting information about it. The code is working in the emulator device, so my guess would be to start looking at the permission rules. Any ideas?
I don't know if this matters, but I am using Ubuntu 10.10 to develop/debug.
回答1:
Is your ROLE Account gmail ID same as the gmail ID configured on the phone ? I did have problems with this. If so, can you try using some other gmail ID on the phone ? For more see this.
回答2:
could that be a permission issue? did you set right permission in the manifest? maybe the emulator is not so strict on lack of permissions (I've experienced that sometimes, some devices worked and other didn't, and all I was missing was a manifest permission)
you have to set both
<permission
android:name="your.packagename.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
and
<uses-permission android:name="your.packagename.matchtracker.permission.C2D_MESSAGE" />
in the main section of your manifest and declare a brodcast receiver with
<receiver
android:name=".push.RegistrationReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="your.packagename" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="your.packagename" />
</intent-filter>
</receiver>
来源:https://stackoverflow.com/questions/5660460/push-notifications-on-emulator-working-but-not-on-real-device