开发者

C2DM: only registered Google account receives messages from server

I seem to be stuck spending hours of trying to figure out what goes wrong. It feels as I am misunderstanding something entirely. So here's the thing:

While trying to make C2DM work, I 1st signed up at Google's C2DM service with a dedicated email adress. That's the one I want to use to send messages from the server to the clients. Then I added code to the client app and registered the device for C2DM. The obtained registration id is sent to the server and stored in the db.

The problem arises when I try to send messages (no matter if I use curlor php) to the devices. Sending to account that I used to signup to the C2DM service in the 1st place works flawlessly. However, sending to any other device fails with Error=NotRegistered. And I just don't get why. I am using the auth key from the signup account and the registration id that I create from the clients. I've (re)-created the registration id like hundreds of times but according to the google code page Error=NotRegistered means that the registration_id is not valid.

Attempt of clarification:

I can perfectly send messages to the registration ID that is linked to the g开发者_运维技巧oogle account I used to sign up to C2DM. All other attempts of sending messages to different registration IDs fail. So I can basically send messages to a single registration ID.

Maybe I should be checking my understanding of C2DM: is the server limited to sending messages to a single device? I thought the server could send messages to each device that has submitted its registration id...

What am I missing/misunderstanding?

Thanks a million, Steff


There's no limitation on which devices it sends to. What's more likely is that the registration ID you're sending to is wrong, or the device you're sending to has not successfully registered.

I would suggest double checking the registration ID, test on another device if you can, make sure when you submit the message to Google's servers you are getting a 200 response, and confirm that the devices are definitely successfully registering to receive C2DM messages.

I'd suggest reading this too. It's the best tutorial on C2DM I've seen. http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html


There is token information in serverside code that allows to chose which devise you want to send a message, have you changed this token (to another device's token) when you want to send a message to another device?


I had the same issue, the future: 'data in the background' (phone config) was disabled. Turning it On solved the case.


I think your problem is that you will always need to use the account you have used to setup the c2dm when registering the client.

You will need to make sure the client phone has a Google account active on the phone (doesn't matter which), but then when you register you need to use the same account that you used to register the app. I think it is used as some type of identifier to know which server should be able to send notifications to the app. An identifier of the phone is probably retrieved from the context by Google. An identifier of the phone for your server should be created by your app (which could be the locally active Google account).


let's say that you have signed up for C2DM with the email 'foo@foo.com'.

Subsequently, you request for a registration ID in your app itself. The reason why you are only able to send push notifications to the registration ID associated with 'foo@foo.com', is because you are supposed to request for registration IDs only with the e-mail address you provided when you signed up for C2DM.

Does this solve your query?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜