OneSignal-Flutter-SDK
OneSignal-Flutter-SDK copied to clipboard
[Bug]: addClickListener not working in IOS when app is in terminated state.
What happened?
Tapping on the message when the app is in killed state doesnt trigger addClickListener
Steps to reproduce?
1. Installed 5.3.4 Version
2. Initialize the code like below before the runApp
static Future<void> initialize() async {
final AppConfig appConfig = locator<AppConfig>();
OneSignal.initialize(appConfig.oneSignalAppId);
OneSignal.Notifications.addClickListener(_onNotificationOpened);
OneSignal.Notifications.addForegroundWillDisplayListener(_onNotificationReceivedInForeground);
}
3. The push notification handler works when the app is in the background or foreground.
4. When the app is in killed state, and when i tap on the message, the "_onNotificationOpened" function isnt trigggered.
5. This is on IOS platform
What did you expect to happen?
I expected the app to trigger the function on tapping the push notification.
OneSignal Flutter SDK version
5.3.4
Which platform(s) are affected?
- [x] iOS
- [ ] Android
Relevant log output
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Hi @preteambuy, thanks for reaching out.
What is in your _onNotificationOpened function? How are you testing that the function is triggered? Print statements and logs are inconsistent when logging very early in the iOS app process. This is a known limitation of iOS logs.
thanks @nan-li . Am pushing the logs to sentry to test it out. This is the function code of _onNotificationOpened
static void _onNotificationOpened(OSNotificationClickEvent event) {
final additionalData = event.notification.additionalData?.cast<String, Object>() ?? {};
Sentry.captureMessage('On Notification Opened: ${additionalData.toString()}');
PushNotificationRouter.handleTarget(additionalData);
}
Is this consistently reproducible for you?
Is this consistently reproducible for you?
Yes it consistent. If the app is killed and when a push notification comes and when i tap on it, it doesnt handle the deeplink. All it does is goes to the landing page
@preteambuy for me it actually crashes. I am using Firebase Auth and the notification triggers it to crash. No logs other than the following from TF.
Incident Identifier: 2E08F249-3447-4806-953F-440A1A318B42
Distributor ID: com.apple.TestFlight
Hardware Model: iPhone17,1
Process: Runner [61992]
Path: /private/var/containers/Bundle/Application/7C163BFD-8BED-41C0-BB63-27B701691D36/Runner.app/Runner
Identifier: com.app.stg
Version: 1.0.4 (52)
AppStoreTools: 17A323
AppVariant: 1:iPhone17,1:26
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.app.stg [27165]
Date/Time: 2025-10-04 13:58:00.5318 +1000
Launch Time: 2025-10-04 13:57:59.0340 +1000
OS Version: iPhone OS 26.0 (23A340)
Release Type: User
Baseband Version: 2.04.06
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001942c5598
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [61992]
Triggered by Thread: 0
Thread 0 Crashed:
0 libswiftCore.dylib 0x00000001942c5598 _assertionFailure(_:_:file:line:flags:) + 172 (AssertCommon.swift:171)
1 FirebaseAuth 0x000000010359e1a8 static Auth.auth() + 72 (Auth.swift:155)
2 FirebaseAuth 0x000000010359e1a8 @objc static Auth.auth() + 196 (/<compiler-generated>:153)
3 Runner 0x0000000102f4aacc -[FLTFirebaseAuthPlugin application:didReceiveRemoteNotification:fetchCompletionHandler:] + 60 (FLTFirebaseAuthPlugin.m:261)
4 Flutter 0x0000000104fd4dc0 -[FlutterPluginAppLifeCycleDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] + 264 (FlutterPluginAppLifeCycleDelegate.mm:269)
5 CoreFoundation 0x000000019708b864 __invoking___ + 148 (:-1)
6 CoreFoundation 0x000000019708b6ec -[NSInvocation invoke] + 424 (NSForwarding.m:3411)
7 OneSignalCore 0x0000000103822ac0 +[SwizzlingForwarder callSelector:onObject:withArgs:] + 228 (SwizzlingForwarder.m:48)
8 OneSignalNotifications 0x000000010388ce38 -[OneSignalNotificationsAppDelegate oneSignalReceiveRemoteNotification:UserInfo:fetchCompletionHandler:] + 496 (UIApplicationDelegate+OneSignalNotifications.m:186)
9 OneSignalNotifications 0x000000010388f3f4 +[OneSignalNotificationsUNUserNotificationCenter callLegacyAppDeletegateSelector:isTextReply:actionIdentifier:userText:fromPresentNotification:withCompletionHandler:] + 1072 (UNUserNotificationCenter+OneSignalNotifications.m:442)
10 OneSignalNotifications 0x000000010388ebf4 +[OneSignalNotificationsUNUserNotificationCenter forwardReceivedNotificationResponseWithCenter:didReceiveNotificationResponse:OneSignalCenter:withCompletionHandler:] + 424 (UNUserNotificationCenter+OneSignalNotifications.m:348)
11 OneSignalNotifications 0x000000010388ed98 -[OneSignalNotificationsUNUserNotificationCenter onesignalUserNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] + 304 (UNUserNotificationCenter+OneSignalNotifications.m:371)
12 UIKitCore 0x000000019dcc6c34 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:] + 3212 (UIApplication.m:11824)
13 UIKitCore 0x000000019dcb1c30 -[UIApplication _callInitializationDelegatesWithActions:forScene:payload:fromOriginatingProcess:] + 4196 (UIApplication.m:3197)
14 UIKitCore 0x000000019dcb5814 -[UIApplication _runWithMainScene:transitionContext:completion:] + 788 (UIApplication.m:4953)
15 UIKitCore 0x000000019d2e3ce8 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 116 (_UISceneLifecycleMultiplexer.m:456)
I have also found a related issue here: https://github.com/firebase/flutterfire/issues/17206