【发布时间】:2017-11-02 13:14:39
【问题描述】:
我通过 FCM 推送通知获得了一个我想在浏览器中打开的链接。我是这样做的:
Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Firebase Push Notification")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(contentIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
但问题是,点击通知时,只有当应用程序处于前台时才会打开浏览器。但是当应用程序被杀死或者它在后台时它不会打开浏览器,它只是打开应用程序。
【问题讨论】:
标签: android push-notification firebase-cloud-messaging