[英]GCM Android Push Notification: send OK but not delivered
I'm trying to send push notification to android devices. 我正在尝试向Android设备发送推送通知。 I have not problem to register the ID of the emulator or the devices, but it's impossibile to receive messages also if the send status is 200 OK . 我没有问题可以注册仿真器或设备的ID,但是如果发送状态为200 OK,也无法接收消息。 I also try to look to firewall settings, but it's already turned off. 我也尝试查看防火墙设置,但已将其关闭。
I tried also to use PushBots service from web: same thing. 我也尝试从Web使用PushBots服务:同样的事情。 Device registered correctly, message sent, but not delivered to emulator or devices. 设备已正确注册,消息已发送,但未传递给仿真器或设备。
It was my mistake. 是我的错 I didn't notice the app was giving me exception when sending push from web for an error in the manifest Receiver. 我没有注意到当从网络发送清单消息接收器中的错误时,应用程序没有给我例外。 Implemented the NotificationManager now I receive the push messagge into device. 现在实现了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.