ben-xD / push

Push notifications in Flutter without firebase_messaging.
https://pub.dev/packages/push
36 stars 22 forks source link

iOS does not trigger Push.instance.onNotificationTap on first push notification tapped #16

Closed ben-aw closed 11 months ago

ben-aw commented 1 year ago

Hello,

Push.instance.onNotificationTap.listen does not trigger for iOS the first time a notification is tapped.

I subscribe to Push.instance.onNotificationTap.listen in the apps main function.

If I minimize the app, send a push notification, tap it to open the app, Push.instance.onNotificationTap.listen is never called.

If I minimize the app again and send another push, it will work.

Android works as it should.

Any thoughts as to what might be causing that? Thanks for your help!

seanhamstra commented 12 months ago

Seeing this as well.

seanhamstra commented 12 months ago

This code appears to be the issue. I already have the app running and then opened a push notification. Since userTapsOnNotificationCount is 0 it skips it. But at this point we already checked Push.instance.notificationTapWhichLaunchedAppFromTerminated and the data was null.

        // Avoid sending the message that launched the app. We will send that one when the user requests for the "Push.instance.notificationTapWhichLaunchedAppFromTerminated" (Dart code)
        if (userTapsOnNotificationCount > 0) {
//            let message = PURemoteMessage.fromNotificationContent(content: response.notification.request.content)
            pushFlutterApi.onNotificationTapData(response.notification.request.content.userInfo as! [String: Any]) { _ in  }
        }
        callOriginalDidReceiveDelegateMethod(center: center, response: response, completionHandler: completionHandler)
        userTapsOnNotificationCount += 1
    }

Screen Shot 2023-07-07 at 9 08 13 AM

ben-xD commented 11 months ago

Looks like @kaiquegazola's MR has fixed it. I've released it as 1.0.1. Thanks for reporting the issue

ben-aw commented 11 months ago

It's working great! Thanks for the fix 👍