GCM stuck on register on 2.3.3 Gingerbread device

泪湿孤枕 提交于 2019-12-08 02:55:39

问题


For some reason, using "GCMRegistrar.register(this, SENDER_ID);" works on 4.0 + devices. However, it stuck at the following message without getting anymore GCM notification from Google.

"Registering app (my package) of senders (my api #)"

1) manifest and receiver should be correct since it's working on 4.2.1.

2) I have google play and linked with google account on 2.3.3 device

I have searched for several day and couldn't find an answer. Anyone know what's wrong or have the same issue?

Thanks


回答1:


I found out it's just because I didn't set the receiver's category correctly.

Since I was putting all my source code in a library project and referencing it with each individual application, I need to rename 3 different places in the manifest.

1)

<permission
        android:name="digital.dispatch.mobilebooker.base.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

to

   <permission
        android:name="digital.dispatch.mobilebooker.(my app name).permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

2)

<uses-permission
        android:name="digital.dispatch.mobilebooker.base.permission.C2D_MESSAGE" />

to

3)

<category android:name="digital.dispatch.mobilebooker.base" />

to

   <category android:name="digital.dispatch.mobilebooker.(my app name)" />

The reason why it worked in 4.0 + device is because I only did the first two but not 3). Since 4.0+ device doesn't care about receiver's category, it worked. However, when I am testing on 2.3.3 device, the category actually matters and causing it not receiving any response.

Hope this will help any other that encounter the same situation.



来源:https://stackoverflow.com/questions/16026736/gcm-stuck-on-register-on-2-3-3-gingerbread-device

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