[英]GCM Android Push Notification: send OK but not delivered
我正在尝试向Android设备发送推送通知。 我没有问题可以注册仿真器或设备的ID,但是如果发送状态为200 OK,也无法接收消息。 我也尝试查看防火墙设置,但已将其关闭。
我也尝试从Web使用PushBots服务:同样的事情。 设备已正确注册,消息已发送,但未传递给仿真器或设备。
是我的错 我没有注意到当从网络发送清单消息接收器中的错误时,应用程序没有给我例外。 现在实现了NotificationManager,我将消息推送到设备中。
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Explicitly specify that GcmMessageHandler will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
GcmMessageHandler.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
mes = extras.getString("title");
sendNotification(mes);
sendAlert(mes);
Log.i("GCM", "Received : (" +messageType+") "+extras.getString("title"));
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.