Java 接收到推送通知,但没有消息
我正在开发一个android应用程序,它需要接收推送通知 推送通知已收到,但没有消息,就在我单击其已启动应用程序的通知中的启动器图标时,未收到任何消息 我在这里处理的只是接收通知的部分,通知是由其他人从服务器发送的,他正在使用VB.net,无法检查他的代码。但是我可以发我的。 我的网上留言:Java 接收到推送通知,但没有消息,java,android,vb.net,push-notification,Java,Android,Vb.net,Push Notification,我正在开发一个android应用程序,它需要接收推送通知 推送通知已收到,但没有消息,就在我单击其已启动应用程序的通知中的启动器图标时,未收到任何消息 我在这里处理的只是接收通知的部分,通知是由其他人从服务器发送的,他正在使用VB.net,无法检查他的代码。但是我可以发我的。 我的网上留言: protected void onMessage(Context context, Intent intent) { Log.i(TAG, "Received message"); String
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
String message = intent.getExtras().getString("price");
generateNotification(context, message);
}
我的世代化
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);
}
请帮助这一点,如果有人想发送消息的VB.net代码,我也可以提供
谢谢,
Asmi我解决了这个问题,因为另一个人(发送推送通知)没有以“价格”的形式发送,而是以“消息”的形式发送。你调试了你的代码吗<代码>字符串消息=intent.getExtras().getString(“价格”);你在这一行得到了什么?谢谢你的消息是空的,现在就解决了