[英]Push Notification received, but no message
I am developing an android app, which needs to receive the push notification. 我正在开发一个Android应用程序,该应用程序需要接收推送通知。
The push notification is received but there is no message, just when I click on launcher icon in notification it launched app, but no message is received. 推送通知已收到,但没有消息,仅当我单击通知中的启动器应用程序启动器图标时,却未收到消息。
I am here handling only the receiving notification part, the notification is sent by some other guy from server and he is using VB.net for that, cant check his code. 我在这里仅处理接收通知部分,该通知是由服务器上的其他人发送的,他为此使用VB.net,无法检查其代码。 But I can post mine. 但是我可以发布我的。 My onMessage: 我的onMessage:
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
String message = intent.getExtras().getString("price");
generateNotification(context, message);
} }
My generateNotification 我的generateNotification
private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, CoursesMainActivity.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}
Please help with this, if someone wants to VB.net code for sending message I can provide that too. 如果有人要VB.net代码发送消息,请帮忙,我也可以提供。
Thanks, Asmi 谢谢,阿斯米
我解决了此问题,因为其他人(发送推送通知)不是将其作为“价格”发送,而是作为“消息”发送
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.