我尝试注册到C2DM但它不起作用。我在项目中添加了com.google.android.c2dm。当我试图找到com.google.android.c2dm.intent.REGISTER
时,它找不到任何内容:
String action = "com.google.android.c2dm.intent.REGISTER";
final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent(action);
List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
list.size()
给0。任何想法?
编辑:mu清单文件包含更正权限:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
答案 0 :(得分:0)
您需要确保在清单文件中拥有com.google.android.c2dm.permission.RECEIVE
权限。
另外,我使用以下样板实现了注册
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
registrationIntent.putExtra("sender", emailOfSender);
startService(registrationIntent);
您可以参考the full docs进行基本设置。