当我发送通知到的设备,该设备获得推送消息,但收到"com.google.android.c2dm.intent.REGISTRATION"的意图,而不是一个"com.google.android.c2dm.intent.RECEIVE" .如果我尝试发送第二个通知,则会收到Google发出的"NotRegistered"错误消息.
设备注册正常(我猜),因为我得到了Auth令牌"APA91 ... -119个字符 - ".
这是我开始注册设备的代码:
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
registrationIntent.putExtra("sender", "EMAIL");
startService(registrationIntent);
Run Code Online (Sandbox Code Playgroud)
发件人(这是在Android设备中完成的):
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", "SAME AS LOGIN"));
nameValuePairs.add(new BasicNameValuePair("Passwd", "****"));
nameValuePairs.add(new BasicNameValuePair("accountType", "HOSTED_OR_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) {
Log.e("C2DM", …Run Code Online (Sandbox Code Playgroud)