简体   繁体   English

当用户在 Flutter 应用程序中单击 Firebase 通知时如何打开链接?

[英]How to open a link when user clicks on Firebase notification in a Flutter App?

I am using Firebase in a Flutter app.我在 Flutter 应用程序中使用 Firebase。 To send notifications, I am using Firebase Messaging plugin.要发送通知,我使用的是Firebase 消息插件。 Whenever I send a notification using Firebase website, the notification just opens the app when user clicks on it.每当我使用 Firebase 网站发送通知时,通知只会在用户单击时打开应用程序。 I want to send a notification which opens a URL instead of the app.我想发送一个打开 URL 而不是应用程序的通知。

I don't know if this information is useful: while composing a notification on Firestore, I always put click_action as FLUTTER_NOTIFICATION_CLICK in "Custom data" section in Additional Options.我不知道这些信息是否有用:在 Firestore 上撰写通知时,我总是将click_actionFLUTTER_NOTIFICATION_CLICK在 Additional Options 的“Custom data”部分。

You can use onLaunch() and onResume() methods to handle notification's opening action.您可以使用 onLaunch() 和 onResume() 方法来处理通知的打开操作。

for more information of notification's reaction on different platforms please see below link: https://pub.dev/packages/firebase_messaging#receiving-messages有关不同平台上通知反应的更多信息,请参见以下链接: https://pub.dev/packages/firebase_messaging#receiving-messages

 _firebaseMessaging.configure(
       onMessage: (Map<String, dynamic> message) async {
         print("onMessage: $message");
       },
       onBackgroundMessage: myBackgroundMessageHandler,
       onLaunch: (Map<String, dynamic> message) async {
         print("onLaunch: $message");
       },
       onResume: (Map<String, dynamic> message) async {
         print("onResume: $message");
       },
     );

And you can use url_launcher to open URLs: https://pub.dev/packages/url_launcher您可以使用 url_launcher 打开 URL: https://pub.dev/packages/url_launcher

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当 iOS 应用程序被暂停/杀死并且用户点击通知时,如何处理 Firebase 推送通知? - How to handle Firebase push notification when iOS app is suspended/killed and user clicks on the notification? 在 firebase_messaging dev14 用户点击通知时如何打开屏幕(背景) - In firebase_messaging dev14 How to open a screen when user clicks on the notification (background) 当用户点击 firebase 动态链接时如何打开应用程序 - How to open the app when user tap on the firebase dynamic link 如何在用户点击时获取Firebase通知正文? - How can I get Firebase Notification Body when user clicks? Firebase - 当用户点击通知时活动重新启动 - Firebase - Activity restarts when user clicks notification Flutter 当应用程序打开时显示通知 Firebase 消息 - Flutter Show Notification when app is open with Firebase Messaging Flutter Firebase 消息 - 应用打开时不显示推送通知 - Flutter Firebase messaging - push notification is not showing when app is open Flutter Firebase - 如何在点击 Firebase 发送的 email 验证链接时打开应用程序? - Flutter Firebase - How to open the app when tapping on email verification link send by Firebase? 在颤振中收到的 Firebase 通知上打开应用程序 - Open app on firebase notification received in flutter 单击网站链接时如何打开应用程序(Firebase 动态链接) - How to open App when click a website link (Firebase Dynamic Link)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM