我想使用试用版的城市飞艇推送通知。
在城市飞艇的注册应用页面上,需要、Google、C2DM、授权令牌。但我无法从谷歌获得C2DM授权令牌。我已经在谷歌注册了我的电子邮件ID,开始使用C2DM,但是他们没有给我任何授权令牌。
如何从谷歌获得C2DM授权令牌?
发布于 2012-04-28 18:43:54
访问此站点,提供详细信息,并获取C2DM授权令牌抛掷
发布于 2012-03-15 10:02:00
你必须等待大约24小时才能获得C2DM的授权,有时甚至更多。但是,当您可以使用curl获得令牌时,您将收到一封电子邮件以进行确认,如文档中所解释的那样。
发布于 2012-03-15 10:08:15
您需要使用Google来请求ClientLogin令牌,使用您的C2DM帐户电子邮件和密码:
public static String getClientLoginAuthToken() {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://www.google.com/accounts/ClientLogin");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("Email", "C2DMEMAILADDRESS));
nameValuePairs.add(new BasicNameValuePair("Passwd", "C2DMPASSWORD));
nameValuePairs.add(new BasicNameValuePair("accountType", "GOOGLE"));
nameValuePairs.add(new BasicNameValuePair("source", "Google-cURL-Example"));
nameValuePairs.add(new BasicNameValuePair("service", "ac2dm"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
Trace.e("HttpResponse", line);
if (line.startsWith("Auth=")) {
return line.substring(5);
}
}
} catch (IOException e) {
e.printStackTrace();
}
Trace.e(TAG, "Failed to get C2DM auth code");
return "";
}有关auth令牌的更多信息,请参见本教程:http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html
https://stackoverflow.com/questions/9717412
复制相似问题