Push notifications on emulator working, but not on real device

倾然丶 夕夏残阳落幕 提交于 2020-01-15 03:44:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!