Android C2DM : Duplicate message to the same device and App

后端 未结 5 455
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-17 21:25

I\'m wondering if anyone has faced this issue with Google C2DM? This is the scenario I am faced with:

  1. User installs the app and registers with C2DM server for
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 21:29

    Yup, I've run into the same issue and in my opinion it's a big oversight in the Android C2DM implementation. iOS handles this much better in that an app can only ever receive notifications for one and only one device token (equivalent of the c2dm registration id)

    The workaround I use is to send the last 10 characters of the registration id as part of the c2dm payload and then in my onMessage method I do the following check:

        if (!regId.endsWith(bundle.getString("regsuffix"))) return null;
    

提交回复
热议问题