OneSignal-Flutter-SDK
OneSignal-Flutter-SDK copied to clipboard
[question]: -[OSNotificationWillDisplayEvent toJson]: unrecognized selector sent to instance 0x28383caf0
How can we help?
2023-09-11 11:42:08.644035+0700 Runner[2055:437404] VERBOSE: onesignalUserNotificationCenter:willPresentNotification:withCompletionHandler: 2023-09-11 11:42:08.644464+0700 Runner[2055:437404] VERBOSE: onesignalUserNotificationCenter:willPresentNotification:withCompletionHandler: Fired! sf 2023-09-11 11:42:08.645027+0700 Runner[2055:437404] VERBOSE: OSNotificationWillDisplayEvent.preventDefault called. 2023-09-11 11:42:08.645317+0700 Runner[2055:437404] -[OSNotificationWillDisplayEvent toJson]: unrecognized selector sent to instance 0x28383caf0 2023-09-11 11:42:08.646077+0700 Runner[2055:437404] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OSNotificationWillDisplayEvent toJson]: unrecognized selector sent to instance 0x28383caf0' *** First throw call stack: (0x1b006de48 0x1a93438d8 0x1b01e282c 0x1b0083f60 0x1b00ec330 0x10449ae00 0x104a3dacc 0x104a3d99c 0x104a412e8 0x1b263a028 0x1b2447c80 0x1b2447a28 0x1b2447868 0x1c5d9566c 0x1c5d954a8 0x1c5d98c24 0x1c5d98b40 0x104a8e05c 0x104a91ad8 0x1c5da2d40 0x1c5da28dc 0x1c5da5184 0x1b0139f34 0x1b014630c 0x1b00ca1d0 0x1b00dfb8c 0x1b00e4ec0 0x1ea13b368 0x1b25da86c 0x1b25da4d0 0x104498770 0x1ce906960) libc++abi: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OSNotificationWillDisplayEvent toJson]: unrecognized selector sent to instance 0x28383caf0' terminating with uncaught exception of type NSException
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Thank you for reporting this issue could you add some reproduction steps? It seems like for some reason it cannot find this method.
Which version of the SDK are you using?
I use version 5.0.0, on ios Runner 5.0.1, in production when get notification crashed app due to this error on Ios Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OSNotificationWillDisplayEvent toJson]: unrecognized selector sent to instance 0x28383caf0'.
how to fix this error ?
@emawby firstly, i config get notification work normally, but when click notification navigate to the app it crashed
Is there anything special about the notification you are sending? I have not been able to reproduce this issue yet
@Chhay67 Thank you for providing this detailed information! Is it possible to share a sample project that is getting the issue or do you have any ideas on how I could setup a project to reproduce the problem? I am not sure what would be causing the iOS bridge to not add the category for the toJson
method.
steps reproduce:
- upgrade package to 5.0.1
- setup notification service file.dart as like migration guide
- initialize onesignal on the top route of the project
- generate setup notification on ios like onesignal document
- run app build successful
- when get notification get crash app
- error : OSFlutterNotifications onWillDisplayNofitication -> [self.chanel invokeMethod:@"OneSignal#onWillDisplayNotification" argument:event.toJson]; unecognized selector sent to instance
- can you provide code to catch exception for this line of code for me to test ? @emawby
@Chhay67 I have followed those steps and unfortunately I am still not able to reproduce the issue. I am not sure if you could catch the error without forking the SDK. We could implement a generic catch for this error but that could hide issues in the future