Android C2DM sender id

大城市里の小女人 提交于 2019-12-12 02:31:05

问题


I've been working with de C2DM for sometime and its has been working perfect. Recently I've bumped into a problem that I can't seem to fix and couldn't anything on this forum that might help. The problem is that I have several apps that use C2DM, I've let all apps register with the same sender id which then registers the users token in my database. The problem if a user has two of my apps A & B (same sender id) and launches app A and I send a push notification to users with app B, user who launched app A the last will receive a message which was actually intended for app B.

My question is there a way to use the same sender id for all apps installed on 1 device?


回答1:


No. A C2DM Registration ID is scoped to one app on one device. If a C2DM message is sent to a Registration ID, it will only ever be delivered to one app. you should have used different C2DM accounts from the start, so each app has its own registration ID. Registration IDs are not per device, they are Per App Per Device.

If you cannot reconfigure the registration IDs then you could use a receiver that then sends a broadcast intent, and both your apps could pick it up by responding to that broadcast. I expect you'd need both apps to listen-and-rebroadcast, but it should work. I'd advise you reconfigure your C2DM usage tho, as your current setup is not ideal and I expect the problem will only get worse.

I assume when you say "sender id" you mean registration id.



来源:https://stackoverflow.com/questions/9915326/android-c2dm-sender-id

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