如何在flutter应用程序中设置setNotificationOpenedHandler方法?

问题描述 投票:0回答:1

为了使用推送通知,我使用了 onesignal。当用户点击通知时,它应该导航到屏幕。为此,我需要 setNotificationOpenedHandler 方法。但是它丢失了。我可以看到 OneSignal.Notifications.addForegroundWillDisplayListener((event) { } )方法但不是

OneSignal.shared.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
    print('"OneSignal: notification opened: ${result}');
});

方法

我阅读了 onesignal 文档,但没有关于它的特殊信息。

flutter dart onesignal
1个回答
0
投票
    ///
    /// This will be called when a notification is received while the app is open.
    /// This code works only -onesignal_flutter: ^5.0.2
    /// You can use that then OneSignal initialized

    OneSignal.Notifications.addClickListener((event) {
      debugPrint("Notification Clicked: $event");
      
    });
© www.soinside.com 2019 - 2024. All rights reserved.