OneSignal-Flutter-SDK icon indicating copy to clipboard operation
OneSignal-Flutter-SDK copied to clipboard

[Bug]: addClickListener not triggered when app is killed

Open Debabrataroy opened this issue 1 year ago • 5 comments
trafficstars

What happened?

OneSignal.Notifications.addClickListener does not fire on the push notification tap when the app is killed (android). Also, I run in release mode but the result is the same.

Here are the logs when I run in release mode. W/FlutterJNI(19398): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 35 W/FlutterJNI(19398): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 14 W/FlutterJNI(19398): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 9

Package Info: onesignal_flutter: dependency: "direct main" description: name: onesignal_flutter url: "https://pub.dev" source: hosted version: "5.1.0"

Let me know if you need anything else. Thanks

Steps to reproduce?

1. kill the app
2. click on the received notification

What did you expect to happen?

addClickListener should be triggered when app open

OneSignal Flutter SDK version

5.1.0

Which platform(s) are affected?

  • [ ] iOS
  • [X] Android

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Debabrataroy avatar Feb 25 '24 12:02 Debabrataroy

I'm also facing the same issue, did any one found the solution!

mwaqassatti avatar Feb 29 '24 07:02 mwaqassatti

Hi @Debabrataroy and @mwaqassatti thank you for reporting. You are seeing this "Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send" error every time notification is clicked from an app killed state? Or only sometimes?

Can you share your flutter doctor?

nan-li avatar Mar 29 '24 18:03 nan-li

Hi @nan-li ! I am facing the same issue. I get the error you mentioned every time a notification is clicked from the app in killed state. If I kill the app again and send a new notification I get the same error multiple times.

This is what I got after 3 notifications:

W/FlutterJNI(11668): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 16 W/FlutterJNI(11668): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 17 W/FlutterJNI(11668): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 9 W/FlutterJNI(11668): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 18 W/FlutterJNI(11668): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 10 W/FlutterJNI(11668): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: OneSignal#notifications. Response ID: 9

This is my flutter doctor:

Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Versione 10.0.22631.3593], locale it-IT) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.6.4) [√] Android Studio (version 2022.1) [√] VS Code (version 1.89.1) [√] Connected device (4 available) [√] Network resources

Do you have any updates?

margherital avatar May 31 '24 10:05 margherital

Been having similar behavior, not only on cold start.

My app uses some native code for some other SDK. The other SDK had GeneratedPluginRegistrant.register(with: "xxx"), and it was placed AFTER GeneratedPluginRegistrant.register(with: self).

The GeneratedPluginRegistrant.register(with: self) has to be at the very end, for both Android and iOS.

example for swift:

        GeneratedPluginRegistrant.register(with: xxx)
        
        GeneratedPluginRegistrant.register(with: self) // this has to be at the very end

        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }

Tested with latest 5.2.2 and working fine.. all handlers as expected.

Hope this helps someone.

ihijazi avatar Aug 03 '24 14:08 ihijazi