简体   繁体   中英

Getting wrong messages for Android GCM push notifications

I have built 3 versions of the same app using the same code base but using different package names and layouts.

One of the features of my app is that it receives push notification messages.

Now, i have installed all 3 apps on my device. So when the push notification comes, i find that it invokes the GCMIntentService onMessage() method of all 3 apps??? Why is this happening? I am a confused. Because i have used different package names for my apps.

Because of this i get 3 notifications for a single notification from the server.

Please help!

Thanks!

Edit: I have confirmed the category from the intent parameter which each of the app receives when the onMessage is invoked. It seems to be receiving the correct category. Could this then be a issue from the server side?

Each of your 3 apps registers to GCM separatelly, and should receive a different registration id, even if the same sender id is used for all three.

Therefore, a single message sent from the server should only teach one app. What I assume happened is that you used the same manifest definitions for all 3 apps. I'm referring to the GCM permissions and the intent service of the broadcast receiver. On older Android versions this would prevent GCM from working at all, but you are probably using an Android 4.x device, in which these permissions are not enforced for some reason.

To fix the problem, use the correct package name in each app manifest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM