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