Android 如何通过Firebase控制台发送包含自定义数据的通知?
我必须在通知中发送一个URL,我想在点击通知后,Chrome会立即打开链接。目前,当我单击通知时,它只打开我的应用程序 对于我想要的行为,我必须在代码中实现哪些更改Android 如何通过Firebase控制台发送包含自定义数据的通知?,android,firebase,android-notifications,firebase-cloud-messaging,firebase-notifications,Android,Firebase,Android Notifications,Firebase Cloud Messaging,Firebase Notifications,我必须在通知中发送一个URL,我想在点击通知后,Chrome会立即打开链接。目前,当我单击通知时,它只打开我的应用程序 对于我想要的行为,我必须在代码中实现哪些更改 private void sendNotification(String messageBody, String title) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CL
private void sendNotification(String messageBody, String title) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
建议:为什么不使用openwith
功能?我认为问题在于“如何在单击通知时打开另一个应用程序?”