Flutterfire: OnResume and OnLaunch never triggered[Android]

Created on 8 Apr 2020  Â·  6Comments  Â·  Source: FirebaseExtended/flutterfire

Hi There,
I am facing issue with firebase_messaging methods never triggered, but I am receiving the notification on my android device without the problem:

_firebaseMessaging.configure(
onLaunch: (Map message) async {
debugPrint('#### onLaunch');
},
onMessage: (Map message) async {
debugPrint('#### onMessage');
},
onResume: (Map message) async {
debugPrint('#### onResume');
});
Here is the output of my flutter doctor:

$ flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E266, locale en-RS)
• Flutter version 1.12.13+hotfix.9 at /Users/lazarjovicic/flutter
• Framework revision f139b11009 (9 days ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/lazarjovicic/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4, Build version 11E146
• CocoaPods version 1.8.4

[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.0.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.43.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.9.1

[✓] Connected device (1 available)
• SM G970F • RF8M728WTMP • android-arm64 • Android 10 (API 29)

• No issues found!
I have followed the instruciton from here https://pub.dev/packages/firebase_messaging#-readme-tab-.
My Manifest:

package="myPackageId">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
     calls FlutterMain.startInitialization(this); in its onCreate method.
     In most cases you can leave this as-is, but you if you want to provide
     additional functionality it is fine to subclass or reimplement
     FlutterApplication and put your custom class here. -->
<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="flutterappnotifications"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <action android:name="FLUTTER_NOTIFICATION_CLICK" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>


Can somebody help me to understand why this is not working? Did I ommited something?

Also, if I add Application.java file, the application is crashing during the instalation.

I managed to print onMessage, but onLanuch and onResume still not working

Please let me know if you need any additional information.
THanks

customer messaging bug documentation

Most helpful comment

@TahaTesser I saw this, but I do not see this field in Firebase console where I can add this map click_action: 'FLUTTER_NOTIFICATION_CLICK'. Can you please pint me in right direction?

Screenshot_20200523-161631

All 6 comments

Hi @lazarvgd
Please take a look at this possible solution
Thank you

@TahaTesser I saw this, but I do not see this field in Firebase console where I can add this map click_action: 'FLUTTER_NOTIFICATION_CLICK'. Can you please pint me in right direction?

@TahaTesser I saw this, but I do not see this field in Firebase console where I can add this map click_action: 'FLUTTER_NOTIFICATION_CLICK'. Can you please pint me in right direction?

Screenshot_20200523-161631

This still doesn't work. Notification is shown but onResume and onLaunch logic is never fired, and I need to save the notification received on shared preferences.

I'm having the same issue, the workaround proposed by @4tKnight works, but I supposed that this click action was being added automatically by the plugin when publishing the local notification in the system tray.
Shouldn't be this explanation included in the plugin readme?

@thearaks it is mentioned in the readme here

Was this page helpful?
0 / 5 - 0 ratings