问题描述
我概括我的计划实施C2DM到应用程序,并有一个基本的(阅读:愚蠢的)。关于该验证令牌
I am outlining my plan to implement C2DM into an application and have a basic (read: stupid) question about the Auth tokens.
客户端服务器需要使用白名单帐户与谷歌C2DM服务注册:
The client server needs to register with the google c2dm service using the white listed account:
有关测试:
curl https://www.google.com/accounts/ClientLogin -d Email=theEmailYouWhitelisted -d Passwd=pass****word -d accountType=HOSTED_OR_GOOGLE -d source="your_app_name_and_ver_for_logging_purposes_only" -d service=ac2dm
我的问题是,这是否会发生一次,每C2DM开户申请 - 即:使用白名单帐户得到一个服务器生成的权威性code,储存,那么每次消息被发送检索和使用:
My question is, does this happen once per application per c2dm account - ie: get the one server generated auth code using your whitelisted account, store it, then every time a message gets sent retrieve it and use:
curl --header "Authorization: GoogleLogin auth=**authFromRegistrationAbove**" "https://android.apis.google.com/c2dm/send" -d registration_id=**phoneRegistrationId(reciever)** -d "data.message=StringToPass" -d collapse_key=something -k
还是你必须申请新的验证code为每封邮件推?
Or do you have to request a new Auth code for every message being pushed?
推荐答案
存储的身份验证令牌为今后推动。从谷歌 C2DM页面:
Store the auth token for future pushes. From the Google C2DM page:
能够存储的ClientLogin验证 令牌和客户端注册的ID。该 的ClientLogin验证令牌被包括在 POST请求的发送头 消息。有关此更多的讨论 话题,请参见的ClientLogin的安装 应用。的服务器应存储 令牌并有一个政策刷新 它定期。
另外请注意,谷歌会定期刷新令牌的更新 - 客户端验证
头。请参阅this讨论对 Android的C2DM
组的详细信息。
Also note that Google will periodically refresh the token in an Update-Client-Auth
header. See this discussion on the android-c2dm
group for details.
这是我的经验,我不知道什么时候或者为什么谷歌选择刷新令牌。它发生在我身上一样频繁每一天,有时每周它。
From my experience, I can't tell when or why Google chooses to refresh the token. It's happened to me as frequently as every day, and sometimes it's every week.
这篇关于Android的C2DM身份验证令牌,一次或每一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!