我正在尝试在我的应用上实施推送通知。我正在使用PHP代码向GCM发送消息。它返回以下信息。
{"multicast_id":5310811111183606373,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1345484510809261%00fbb339d652b5b3"}]}
但推送通知不会进入我的Android设备。我身边有什么问题吗?
Android清单中的权限如下所示。
<receiver
android:name="com.projects.XXXX.GcmReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.projects.XXX" />
</intent-filter>
</receiver>
<permission
android:name="com.projects.xxxx.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.projects.xxxx.permission.C2D_MESSAGE" />
<uses-permission android:name="com.projects.xxxx.permission.RECEIVE" />
广播接收器
public class GcmReceiver extends BroadcastReceiver {
public static final int NOTIFICATION_ID = 1;
private static NotificationManager mNotificationManager;
NotificationCompat.Builder builder;
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
String message = intent.getExtras().getString("message");
if(message != null){
generateNotification(context, message);
}
}