1

I implemented GCM to my app as described Getting Started page and used gcm.jar and gcm-server.jar helper libraries for easier implementation.

But I think I misunderstood something with GCM; beucase I couldn't achieve what i want.

I want that register devices with another key information not only registerId. For example this is a weather application and user may want to get notifications about one city or more cities. To achieve this, server needs the city name or postal code to fetch weather information from other sources and push back to the registered devices if there is any change at releated cities.

I register device when user stated to get notifications about something particular (for example city).

However GCMRegistrar.register method only takes 2 arguments, one for context and one for senderID.

How can I send additional parameters to application server?

edit: I implemented GCMIntentService and onRegistered method. I can send additional information from here with directly calling server; but i lose additional information when onRegistered method called.

4

1 回答 1

2

没有什么可以阻止您实现自己的代码以将信息发送到您的应用服务器。我已经用我的应用程序做到了。在 GCMIntentService 类中,您创建了插入代码以在您的内部执行此操作

protected void onRegistered(Context context,String regId)

方法。您会注意到 google 的 GCM 库实际上并没有像 C2DM 那样进行任何 3rd 方应用服务器注册。如果你愿意,你可以选择使用谷歌应用引擎。

于 2012-07-05T11:53:31.083 回答