简体   繁体   English

推送通知已收到,但未收到任何消息

[英]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.

相关问题 有时未收到推送通知 firebase - Push notification firebase sometime not received Android Firebase 后台未收到推送通知? - Android Firebase Push notification not received in background? Android:即使触发了onMessageReceived方法,也未收到Firebase推送通知 - Android : Firebase push notification not received even though onMessageReceived method is triggered 如何打开一个活动以显示消息推送通知? - how to open an activity to display message push notification? 推送通知发送给发送消息的用户,而不是接收者 - Push notification is sent to the user that sends the message and not to the receiver Firebase 新聊天消息推送通知 - Firebase push notification on new chat message 单击通知选项卡中的推送通知消息,如何打开特定片段? - How to open the particular fragment on the click of the push notification message in the notification tab? 单击推送消息后访问推送通知内容(Android) - Access the Push notification content after a click on the push message (Android) "将字节数组(接收到的 mqtt 消息)比较为零以发送通知" - Compare byte array (received mqtt message) to zero to send notification Android GCM Java Server - 无消息数据的推送通知 - Android GCM Java Server - Push Notification without message data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM