firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.46k stars 3.91k forks source link

Unable to use onBackgroundMessage in Firebase Cloud Messaging #2387

Closed dvdlg closed 3 years ago

dvdlg commented 4 years ago

I am trying to implement an app with notifications. I followed the official instructions of firebase_messaging (https://pub.dev/packages/firebase_messaging), and everything worked as promissed, but there is something I don't understand. I was able to trigger onMessage, onLaunch and onResume and make the UI respond properly (showing the user the recieved message). But when onBackgroundMessage is triggered, I can only print the message to the debugging console. I looked all over the internet, but it seems like that's how all discussions end. What can I do inside onBackgroundMessage? I failed to find any way to show to the user that the message had been recieved. I tried to navigate using a global navigator key but navigatorKey.currentState is null while running in background. I tried to update a provider, but it was also null. I even tried to update a global variable but it was the old value again when the app resumed to foreground. Could anyone please publish code example in which onBackgroundMessage has any impact on the user? (not only printing to the console).

The reason that I really want to use onBackgroundMessage is because when I get the notification while running in background, onResume and onLaunch are triggered only if I click the notification. If I click the app icon, the notification stays and nothing is triggered. I have no way to tell the user about the notification. If someone finds a way to read notifications that the user didn't click yet, that would help even more.

This is my code. When pressing button 1, a notification is sent after a delay of 5 seconds (to let the user time to put the app in background). When pressing button 2, a data message is sent. Uppon recieving the message the three counters are incremented. But in some cases nothing happens.

expected result In all scenarios all three counters should increment.

Actual result In case the app was running in background while the message was sent, after resuming to the app nothing happend (both with buttom 1 and 2).

import 'dart:convert';

import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';

void main() => runApp(MyApp());

class MyProvider extends StatefulWidget {
  final Widget child;
  const MyProvider({Key key, this.child}) : super(key: key);

  @override
  MyProviderState createState() => MyProviderState();
}

class MyProviderState extends State<MyProvider> {
  int counter = 0;

  void increment() {
    setState(() {
      counter += 1;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Provider.value(
      value: counter,
      child: Provider.value(
        value: this,
        child: widget.child,
      ),
    );
  }
}

const String serverToken = /* put your own server token here */;
final FirebaseMessaging firebaseMessaging = FirebaseMessaging();

int globalInt = 0;
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
final GlobalKey<MyProviderState> providerKey = GlobalKey<MyProviderState>();

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print('Rebuild MyApp');
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
    SharedPreferences.getInstance().then((prefs) => prefs.setString('counter3', '0'));
    return MyProvider(
      key: providerKey,
      child: MaterialApp(
        title: 'Flutter Demo',
        navigatorKey: navigatorKey,
        home: HomePage(),
        routes: {},
      ),
    );
  }
}

Future<void> sendNotification(int buttonNumber) async {
  print('Pressed button $buttonNumber');
  // This delay is to give the user time to move the app to background.
  await Future.delayed(Duration(seconds: 5));
  await http.post(
    'https://fcm.googleapis.com/fcm/send',
    headers: <String, String>{
      'Content-Type': 'application/json',
      'Authorization': 'key=$serverToken',
    },
    body: jsonEncode(
      <String, dynamic>{
        'notification': buttonNumber == 1
            ? <String, dynamic>{
                'body': 'This is a body',
                'title': 'This is a title',
              }
            : <String, dynamic>{},
        'priority': 'high',
        'data': <String, dynamic>{
          'click_action': 'FLUTTER_NOTIFICATION_CLICK',
          'id': '1',
          'status': 'done',
          'action': buttonNumber,
        },
        'to': await firebaseMessaging.getToken(),
      },
    ),
  );
  print('Sent notification');
}

Future<void> handleNotification(Map<String, dynamic> message) async {
  int action = int.parse(message['data']['action']);
  print('>>> Got notification with action $action');
  print('>>> navigatorKey.currentState = ${navigatorKey.currentState}');
  print('>>> providerKey.currentState = ${providerKey.currentState}');
  if (navigatorKey.currentState != null) {
    print('>>> You are lucky! The app is in foreground or the user clicked the notification.');
    print('>>> You can update the UI or navigate to inform the user of the notification.');
  } else {
    print(
        '>>> You are helpless! onBackgroundMessage was triggered but there is nothing you can do to inform the user.');
  }
  // Increment counter1
  print('>>> trying to increment counter1 from $globalInt to ${globalInt + 1}');
  globalInt += 1;
  // Increment counter2
  try {
    print('>>> trying to increment counter2');
    providerKey.currentState.increment();
  } catch (e) {
    print('>>> Error: <<$e>>');
  }
  // Increment counter3
  try {
    print('>>> trying to increment counter3');
    final SharedPreferences prefs = await SharedPreferences.getInstance();
    final int value = int.parse(prefs.getString('counter3'));
    prefs.setString('counter3', '${value + 1}');
  } catch (e) {
    print('>>> Error: <<$e>>');
  }
}

Future<void> onBackgroundMessage(Map<String, dynamic> message) async {
  print('>>> onBackgroundMessage');
  await handleNotification(message);
}

Future<void> onMessage(Map<String, dynamic> message) async {
  print('>>> onMessage');
  await handleNotification(message);
}

Future<void> onResume(Map<String, dynamic> message) async {
  print('>>> onResume');
  await handleNotification(message);
}

Future<void> onLaunch(Map<String, dynamic> message) async {
  print('>>> onLaunch');
  await handleNotification(message);
}

class HomePage extends StatefulWidget {
  @override
  _HomePage createState() => _HomePage();
}

class _HomePage extends State<HomePage> {
  int counter1 = 0;
  int counter2 = 0;
  int counter3 = 0;

  @override
  void initState() {
    super.initState();
    firebaseMessaging.requestNotificationPermissions(
        const IosNotificationSettings(sound: true, badge: true, alert: true, provisional: false));
    firebaseMessaging.configure(
      onBackgroundMessage: onBackgroundMessage,
      onMessage: onMessage,
      onResume: onResume,
      onLaunch: onLaunch,
    );
  }

  @override
  Widget build(BuildContext context) {
    counter1 = globalInt;
    counter2 = Provider.of<int>(context);
    SharedPreferences.getInstance().then((prefs) {
      setState(() {
        counter3 = int.parse(prefs.getString('counter3'));
      });
    });
    return Scaffold(
      body: Column(
        children: [
          Expanded(
            child: SizedBox(height: 50),
          ),
          Expanded(
            child: Text('$counter1', textScaleFactor: 3.5),
          ),
          Expanded(
            child: Text('$counter2', textScaleFactor: 3.5),
          ),
          Expanded(
            child: Text('$counter3', textScaleFactor: 3.5),
          ),
          Expanded(
            child: Row(children: [
              Expanded(
                child: FloatingActionButton(
                  onPressed: () => sendNotification(1),
                  child: Text('1', textScaleFactor: 2),
                ),
              ),
              Expanded(
                child: FloatingActionButton(
                  onPressed: () => sendNotification(2),
                  child: Text('2', textScaleFactor: 2),
                ),
              ),
            ]),
          ),
        ],
      ),
    );
  }
}
TahaTesser commented 4 years ago

Hi @dvdlg can you please provide your flutter doctor -v and flutter run --verbose? Thank you

dvdlg commented 4 years ago

my flutter doctor:

PS C:\src\flutter\bin> .\flutter doctor -v
[√] Flutter (Channel unknown, v1.12.13+hotfix.7, on Microsoft Windows [Version 10.0.18362.720], locale he-IL)
    • Flutter version 1.12.13+hotfix.7 at C:\src\flutter
    • Framework revision 9f5ff2306b (3 months ago), 2020-01-26 22:38:26 -0800
    • Engine revision a67792536c
    • Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\USER\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[!] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.44.2)
    • VS Code at C:\Users\USER\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.9.1

[√] Connected device (1 available)
    • SM G960F • 27b8a801df1c7ece • android-arm64 • Android 8.0.0 (API 26)

! Doctor found issues in 2 categories.

my flutter run --verbose

[  +31 ms] executing: [C:\src\flutter\] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +73 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 9f5ff2306bb3e30b2b98eee79cd231b1336f41f4
[        ] executing: [C:\src\flutter\] git describe --match v*.*.* --first-parent --long --tags
[  +55 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.12.13+hotfix.7-0-g9f5ff2306
[   +9 ms] executing: [C:\src\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[  +48 ms] Exit code 128 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] fatal: HEAD does not point to a branch
[  +14 ms] executing: [C:\src\flutter\] git rev-parse --abbrev-ref HEAD
[  +45 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] HEAD
[ +145 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[  +50 ms] Exit code 0 from: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[        ] List of devices attached
           27b8a801df1c7ece       device product:starltexx model:SM_G960F device:starlte transport_id:48
[  +34 ms] C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 27b8a801df1c7ece shell getprop
[ +209 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[   +8 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[  +13 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +107 ms] Found plugin firebase_core at C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.4.4+3\
[  +33 ms] Found plugin firebase_core_web at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core_web-0.1.1+2\
[  +14 ms] Found plugin firebase_messaging at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-6.0.13\
[  +93 ms] Found plugin shared_preferences at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.6+3\
[  +14 ms] Found plugin shared_preferences_macos at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_macos-0.0.1+6\
[  +18 ms] Found plugin shared_preferences_web at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_web-0.1.2+4\
[ +112 ms] Found plugin firebase_core at C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.4.4+3\
[   +9 ms] Found plugin firebase_core_web at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core_web-0.1.1+2\
[   +4 ms] Found plugin firebase_messaging at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-6.0.13\
[  +40 ms] Found plugin shared_preferences at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.6+3\
[  +11 ms] Found plugin shared_preferences_macos at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_macos-0.0.1+6\
[   +4 ms] Found plugin shared_preferences_web at
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_web-0.1.2+4\
[  +95 ms] Generating
C:\Users\USER\Desktop\flutter\test_app\test_app\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[  +80 ms] ro.hardware = samsungexynos9810
[  +57 ms] Launching lib\main.dart on SM G960F in debug mode...
[  +15 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\build-tools\28.0.3\aapt dump xmltree
C:\Users\USER\Desktop\flutter\test_app\test_app\build\app\outputs\apk\app.apk AndroidManifest.xml
[  +27 ms] Exit code 0 from: C:\Users\USER\AppData\Local\Android\sdk\build-tools\28.0.3\aapt dump xmltree
C:\Users\USER\Desktop\flutter\test_app\test_app\build\app\outputs\apk\app.apk AndroidManifest.xml
[   +4 ms] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
               A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
               A: package="com.example.test_app" (Raw: "com.example.test_app")
               A: platformBuildVersionCode=(type 0x10)0x1c
               A: platformBuildVersionName=(type 0x10)0x9
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: uses-permission (line=15)
                 A: android:name(0x01010003)="android.permission.ACCESS_NETWORK_STATE" (Raw:
                 "android.permission.ACCESS_NETWORK_STATE")
               E: uses-permission (line=16)
                 A: android:name(0x01010003)="android.permission.WAKE_LOCK" (Raw: "android.permission.WAKE_LOCK")
               E: uses-permission (line=17)
                 A: android:name(0x01010003)="com.google.android.c2dm.permission.RECEIVE" (Raw:
                 "com.google.android.c2dm.permission.RECEIVE")
               E: application (line=25)
                 A: android:label(0x01010001)="test_app" (Raw: "test_app")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="com.example.test_app.Application" (Raw:
                 "com.example.test_app.Application")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw:
                 "androidx.core.app.CoreComponentFactory")
                 E: activity (line=31)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.test_app.MainActivity" (Raw:
                   "com.example.test_app.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: intent-filter (line=38)
                     E: action (line=39)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=41)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw:
                       "android.intent.category.LAUNCHER")
                   E: intent-filter (line=43)
                     E: action (line=44)
                       A: android:name(0x01010003)="FLUTTER_NOTIFICATION_CLICK" (Raw: "FLUTTER_NOTIFICATION_CLICK")
                     E: category (line=46)
                       A: android:name(0x01010003)="android.intent.category.DEFAULT" (Raw:
                       "android.intent.category.DEFAULT")
                 E: meta-data (line=53)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
                 E: service (line=57)
                   A: android:name(0x01010003)="com.google.firebase.components.ComponentDiscoveryService" (Raw:
                   "com.google.firebase.components.ComponentDiscoveryService")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   A: android:directBootAware(0x01010505)=(type 0x12)0xffffffff
                   E: meta-data (line=61)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:io.flutter.plugins.firebase.core.Flutte                     rFirebaseAppRegistrar" (Raw:
                     "com.google.firebase.components:io.flutter.plugins.firebase.core.FlutterFirebaseAppRegistrar")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=64)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:io.flutter.plugins.firebasemessaging.Fl                     utterFirebaseAppRegistrar" (Raw:
                     "com.google.firebase.components:io.flutter.plugins.firebasemessaging.FlutterFirebaseAppRegistrar                     ")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=67)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:com.google.firebase.messaging.FirebaseM                     essagingRegistrar" (Raw:
                     "com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=70)
                     A: android:name(0x01010003)="com.google.firebase.components:com.google.firebase.iid.Registrar"
                     (Raw: "com.google.firebase.components:com.google.firebase.iid.Registrar")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=73)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:com.google.firebase.datatransport.Trans                     portRegistrar" (Raw:
                     "com.google.firebase.components:com.google.firebase.datatransport.TransportRegistrar")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=76)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:com.google.firebase.installations.Fireb                     aseInstallationsRegistrar" (Raw:
                     "com.google.firebase.components:com.google.firebase.installations.FirebaseInstallationsRegistrar                     ")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                 E: service (line=80)
                   A: android:name(0x01010003)="io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService"                   (Raw: "io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService")
                   E: intent-filter (line=81)
                     E: action (line=82)
                       A: android:name(0x01010003)="com.google.firebase.MESSAGING_EVENT" (Raw:
                       "com.google.firebase.MESSAGING_EVENT")
                 E: service (line=89)
                   A: android:name(0x01010003)="com.google.firebase.messaging.FirebaseMessagingService" (Raw:
                   "com.google.firebase.messaging.FirebaseMessagingService")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   E: intent-filter (line=92)
                     A: android:priority(0x0101001c)=(type 0x10)0xfffffe0c
                     E: action (line=93)
                       A: android:name(0x01010003)="com.google.firebase.MESSAGING_EVENT" (Raw:
                       "com.google.firebase.MESSAGING_EVENT")
                 E: receiver (line=97)
                   A: android:name(0x01010003)="com.google.firebase.iid.FirebaseInstanceIdReceiver" (Raw:
                   "com.google.firebase.iid.FirebaseInstanceIdReceiver")
                   A: android:permission(0x01010006)="com.google.android.c2dm.permission.SEND" (Raw:
                   "com.google.android.c2dm.permission.SEND")
                   A: android:exported(0x01010010)=(type 0x12)0xffffffff
                   E: intent-filter (line=101)
                     E: action (line=102)
                       A: android:name(0x01010003)="com.google.android.c2dm.intent.RECEIVE" (Raw:
                       "com.google.android.c2dm.intent.RECEIVE")
                 E: provider (line=106)
                   A: android:name(0x01010003)="com.google.firebase.provider.FirebaseInitProvider" (Raw:
                   "com.google.firebase.provider.FirebaseInitProvider")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   A: android:authorities(0x01010018)="com.example.test_app.firebaseinitprovider" (Raw:
                   "com.example.test_app.firebaseinitprovider")
                   A: android:initOrder(0x0101001a)=(type 0x10)0x64
                 E: activity (line=112)
                   A: android:theme(0x01010000)=@0x1030010
                   A: android:name(0x01010003)="com.google.android.gms.common.api.GoogleApiActivity" (Raw:
                   "com.google.android.gms.common.api.GoogleApiActivity")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                 E: meta-data (line=117)
                   A: android:name(0x01010003)="com.google.android.gms.version" (Raw:
                   "com.google.android.gms.version")
                   A: android:value(0x01010024)=@0x7f060000
                 E: service (line=121)
                   A:
                   android:name(0x01010003)="com.google.android.datatransport.runtime.backends.TransportBackendDiscov                   ery" (Raw: "com.google.android.datatransport.runtime.backends.TransportBackendDiscovery")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   E: meta-data (line=124)
                     A: android:name(0x01010003)="backend:com.google.android.datatransport.cct.CctBackendFactory"
                     (Raw: "backend:com.google.android.datatransport.cct.CctBackendFactory")
                     A: android:value(0x01010024)="cct" (Raw: "cct")
                 E: service (line=128)
                   A:
                   android:name(0x01010003)="com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInf                   oSchedulerService" (Raw:
                   "com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService")
                   A: android:permission(0x01010006)="android.permission.BIND_JOB_SERVICE" (Raw:
                   "android.permission.BIND_JOB_SERVICE")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                 E: receiver (line=134)
                   A:
                   android:name(0x01010003)="com.google.android.datatransport.runtime.scheduling.jobscheduling.AlarmM                   anagerSchedulerBroadcastReceiver" (Raw:
                   "com.google.android.datatransport.runtime.scheduling.jobscheduling.AlarmManagerSchedulerBroadcastR                   eceiver")
                   A: android:exported(0x01010010)=(type 0x12)0x0
[  +47 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 27b8a801df1c7ece shell -x
logcat -v time -s flutter
[  +14 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe version
[  +50 ms] Android Debug Bridge version 1.0.41
           Version 29.0.4-5871666
           Installed as C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe
[   +5 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe start-server
[  +34 ms] Building APK
[  +32 ms] Running Gradle task 'assembleDebug'...
[   +9 ms] gradle.properties already sets `android.enableR8`
[   +6 ms] Using gradle from C:\Users\USER\Desktop\flutter\test_app\test_app\android\gradlew.bat.
[  +20 ms] executing: C:\Program Files\Android\Android Studio\jre\bin\java -version
[ +127 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jre\bin\java -version
[   +3 ms] openjdk version "1.8.0_202-release"
           OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
           OpenJDK 64-Bit Server VM (build 25.202-b03, mixed mode)
[   +6 ms] executing: [C:\Users\USER\Desktop\flutter\test_app\test_app\android\]
C:\Users\USER\Desktop\flutter\test_app\test_app\android\gradlew.bat -Pverbose=true
-Ptarget=C:\Users\USER\Desktop\flutter\test_app\test_app\lib\main.dart -Ptrack-widget-creation=true
-Pfilesystem-scheme=org-dartlang-root -Ptarget-platform=android-arm64 assembleDebug
[ +230 ms] I/flutter (24276): Rebuild MyApp
[  +10 ms] I/flutter (24485): Rebuild MyApp
[   +8 ms] I/flutter (24605): Rebuild MyApp
[ +222 ms] I/flutter (27725): Rebuild MyApp
[   +3 ms] E/flutter (27725): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Invalid argument(s):
The source must not be null
[   +6 ms] E/flutter (27725): #0      int.parse (dart:core-patch/integers_patch.dart:53:25)
[        ] E/flutter (27725): #1      _HomePage.build.<anonymous closure>.<anonymous closure>
(package:test_app/main.dart:184:24)
[   +5 ms] E/flutter (27725): #2      State.setState (package:flutter/src/widgets/framework.dart:1148:30)
[   +1 ms] E/flutter (27725): #3      _HomePage.build.<anonymous closure> (package:test_app/main.dart:183:7)
[        ] E/flutter (27725): #4      _rootRunUnary (dart:async/zone.dart:1134:38)
[        ] E/flutter (27725): #5      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
[        ] E/flutter (27725): #6      _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
[        ] E/flutter (27725): #7      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:680:45)
[        ] E/flutter (27725): #8      Future._propagateToListeners (dart:async/future_impl.dart:709:32)
[        ] E/flutter (27725): #9      Future._propagateToListeners (dart:async/future_impl.dart:607:9)
[        ] E/flutter (27725): #10     Future._completeWithValue (dart:async/future_impl.dart:524:5)
[        ] E/flutter (27725): #11     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7)
[  +11 ms] E/flutter (27725): #12     _rootRun (dart:async/zone.dart:1126:13)
[   +4 ms] E/flutter (27725): #13     _CustomZone.run (dart:async/zone.dart:1023:19)
[   +2 ms] E/flutter (27725): #14     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
[   +9 ms] E/flutter (27725): #15     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:965:23)
[   +1 ms] E/flutter (27725): #16     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
[   +3 ms] E/flutter (27725): #17     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
[  +12 ms] E/flutter (27725):
[   +4 ms] I/flutter (27725): Rebuild MyApp
[  +12 ms] I/flutter (28401): Rebuild MyApp
[ +101 ms] I/flutter (30290): Rebuild MyApp
[   +8 ms] E/flutter (30290): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Invalid argument(s):
The source must not be null
[   +8 ms] E/flutter (30290): #0      int.parse (dart:core-patch/integers_patch.dart:53:25)
[   +1 ms] E/flutter (30290): #1      _HomePage.build.<anonymous closure>.<anonymous closure>
(package:test_app/main.dart:184:24)
[   +4 ms] E/flutter (30290): #2      State.setState (package:flutter/src/widgets/framework.dart:1148:30)
[   +5 ms] E/flutter (30290): #3      _HomePage.build.<anonymous closure> (package:test_app/main.dart:183:7)
[   +3 ms] E/flutter (30290): #4      _rootRunUnary (dart:async/zone.dart:1134:38)
[   +1 ms] E/flutter (30290): #5      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
[   +1 ms] E/flutter (30290): #6      _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
[        ] E/flutter (30290): #7      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:680:45)
[   +1 ms] E/flutter (30290): #8      Future._propagateToListeners (dart:async/future_impl.dart:709:32)
[        ] E/flutter (30290): #9      Future._propagateToListeners (dart:async/future_impl.dart:607:9)
[   +8 ms] E/flutter (30290): #10     Future._completeWithValue (dart:async/future_impl.dart:524:5)
[   +1 ms] E/flutter (30290): #11     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7)
[   +1 ms] E/flutter (30290): #12     _rootRun (dart:async/zone.dart:1126:13)
[        ] E/flutter (30290): #13     _CustomZone.run (dart:async/zone.dart:1023:19)
[        ] E/flutter (30290): #14     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
[   +7 ms] E/flutter (30290): #15     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:965:23)
[   +3 ms] E/flutter (30290): #16     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
[   +1 ms] E/flutter (30290): #17     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
[   +1 ms] E/flutter (30290):
[  +10 ms] I/flutter (30290): Pressed button 1
[   +2 ms] I/flutter (30290): >>> onMessage
[   +1 ms] I/flutter (30290): >>> Got notification with action 1
[   +1 ms] I/flutter (30290): >>> navigatorKey.currentState = NavigatorState#282e4(tickers: tracking 1 ticker)
[   +1 ms] I/flutter (30290): >>> providerKey.currentState = MyProviderState#f3dee
[   +1 ms] I/flutter (30290): >>> You are lucky! The app is in foreground or the user clicked the notification.
[   +9 ms] I/flutter (30290): >>> You can update the UI or navigate to inform the user of the notification.
[   +1 ms] I/flutter (30290): >>> trying to increment counter1 from 0 to 1
[   +1 ms] I/flutter (30290): >>> trying to increment counter2
[   +1 ms] I/flutter (30290): >>> trying to increment counter3
[        ] I/flutter (30290): >>> onMessage
[        ] I/flutter (30290): >>> Got notification with action 1
[        ] I/flutter (30290): >>> navigatorKey.currentState = NavigatorState#282e4(tickers: tracking 1 ticker)
[   +1 ms] I/flutter (30290): >>> providerKey.currentState = MyProviderState#f3dee
[   +4 ms] I/flutter (30290): >>> You are lucky! The app is in foreground or the user clicked the notification.
[   +2 ms] I/flutter (30290): >>> You can update the UI or navigate to inform the user of the notification.
[   +2 ms] I/flutter (30290): >>> trying to increment counter1 from 1 to 2
[   +1 ms] I/flutter (30290): >>> trying to increment counter2
[   +1 ms] I/flutter (30290): >>> trying to increment counter3
[   +5 ms] I/flutter (30290): Sent notification
[   +3 ms] I/flutter (30290): Pressed button 2
[   +1 ms] I/flutter (30290): Sent notification
[   +2 ms] I/flutter (30290): >>> onBackgroundMessage
[   +1 ms] I/flutter (30290): >>> Got notification with action 2
[   +3 ms] I/flutter (30290): >>> navigatorKey.currentState = null
[   +3 ms] I/flutter (30290): >>> providerKey.currentState = null
[   +1 ms] I/flutter (30290): >>> You are helpless! onBackgroundMessage was triggered but there is nothing you can doto inform the user.
[   +1 ms] I/flutter (30290): >>> trying to increment counter1 from 0 to 1
[   +1 ms] I/flutter (30290): >>> trying to increment counter2
[   +1 ms] I/flutter (30290): >>> Error: <<NoSuchMethodError: The method 'increment' was called on null.
[   +9 ms] I/flutter (30290): Receiver: null
[   +1 ms] I/flutter (30290): Tried calling: increment()>>
[   +1 ms] I/flutter (30290): >>> trying to increment counter3
[   +1 ms] I/flutter (30290): >>> Error: <<MissingPluginException(No implementation found for method getAll on
channel plugins.flutter.io/shared_preferences)>>
[+1993 ms] > Task :app:compileFlutterBuildDebug UP-TO-DATE
[  +86 ms] > Task :app:packLibsflutterBuildDebug UP-TO-DATE
[   +5 ms] > Task :app:preBuild UP-TO-DATE
[   +3 ms] > Task :app:preDebugBuild UP-TO-DATE
[  +21 ms] > Task :firebase_core:preBuild UP-TO-DATE
[   +4 ms] > Task :firebase_core:preDebugBuild UP-TO-DATE
[   +5 ms] > Task :firebase_core_web:preBuild UP-TO-DATE
[   +4 ms] > Task :firebase_core_web:preDebugBuild UP-TO-DATE
[   +3 ms] > Task :firebase_core_web:compileDebugAidl NO-SOURCE
[   +5 ms] > Task :firebase_messaging:preBuild UP-TO-DATE
[  +23 ms] > Task :firebase_messaging:preDebugBuild UP-TO-DATE
[   +2 ms] > Task :shared_preferences:preBuild UP-TO-DATE
[   +1 ms] > Task :shared_preferences:preDebugBuild UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:preBuild UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:preDebugBuild UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:compileDebugAidl NO-SOURCE
[   +8 ms] > Task :shared_preferences_web:preBuild UP-TO-DATE
[  +15 ms] > Task :shared_preferences_web:preDebugBuild UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:compileDebugAidl NO-SOURCE
[   +1 ms] > Task :shared_preferences:compileDebugAidl NO-SOURCE
[   +4 ms] > Task :firebase_core:compileDebugAidl NO-SOURCE
[   +3 ms] > Task :firebase_messaging:compileDebugAidl NO-SOURCE
[   +2 ms] > Task :app:compileDebugAidl NO-SOURCE
[   +1 ms] > Task :firebase_core:packageDebugRenderscript NO-SOURCE
[   +4 ms] > Task :firebase_core_web:packageDebugRenderscript NO-SOURCE
[   +3 ms] > Task :firebase_messaging:packageDebugRenderscript NO-SOURCE
[   +1 ms] > Task :shared_preferences:packageDebugRenderscript NO-SOURCE
[   +1 ms] > Task :shared_preferences_macos:packageDebugRenderscript NO-SOURCE
[   +9 ms] > Task :shared_preferences_web:packageDebugRenderscript NO-SOURCE
[   +1 ms] > Task :app:compileDebugRenderscript NO-SOURCE
[   +1 ms] > Task :app:checkDebugManifest UP-TO-DATE
[  +21 ms] > Task :app:generateDebugBuildConfig UP-TO-DATE
[  +29 ms] > Task :app:cleanMergeDebugAssets
[   +3 ms] > Task :app:mergeDebugShaders UP-TO-DATE
[  +10 ms] > Task :app:compileDebugShaders UP-TO-DATE
[   +1 ms] > Task :app:generateDebugAssets UP-TO-DATE
[   +3 ms] > Task :firebase_core:mergeDebugShaders UP-TO-DATE
[   +6 ms] > Task :firebase_core:compileDebugShaders UP-TO-DATE
[   +3 ms] > Task :firebase_core:generateDebugAssets UP-TO-DATE
[   +1 ms] > Task :firebase_core:packageDebugAssets UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:mergeDebugShaders UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:compileDebugShaders UP-TO-DATE
[   +8 ms] > Task :firebase_core_web:generateDebugAssets UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:packageDebugAssets UP-TO-DATE
[   +4 ms] > Task :firebase_messaging:mergeDebugShaders UP-TO-DATE
[   +4 ms] > Task :firebase_messaging:compileDebugShaders UP-TO-DATE
[   +1 ms] > Task :firebase_messaging:generateDebugAssets UP-TO-DATE
[   +5 ms] > Task :firebase_messaging:packageDebugAssets UP-TO-DATE
[   +3 ms] > Task :shared_preferences:mergeDebugShaders UP-TO-DATE
[   +1 ms] > Task :shared_preferences:compileDebugShaders UP-TO-DATE
[   +1 ms] > Task :shared_preferences:generateDebugAssets UP-TO-DATE
[   +4 ms] > Task :shared_preferences:packageDebugAssets UP-TO-DATE
[   +5 ms] > Task :shared_preferences_macos:mergeDebugShaders UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:compileDebugShaders UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:generateDebugAssets UP-TO-DATE
[   +6 ms] > Task :shared_preferences_macos:packageDebugAssets UP-TO-DATE
[   +2 ms] > Task :shared_preferences_web:mergeDebugShaders UP-TO-DATE
[   +3 ms] > Task :shared_preferences_web:compileDebugShaders UP-TO-DATE
[   +4 ms] > Task :shared_preferences_web:generateDebugAssets UP-TO-DATE
[   +3 ms] > Task :shared_preferences_web:packageDebugAssets UP-TO-DATE
[   +1 ms] > Task :app:mergeDebugAssets
[ +351 ms] > Task :app:copyFlutterAssetsDebug
[   +6 ms] > Task :app:mainApkListPersistenceDebug UP-TO-DATE
[   +2 ms] > Task :app:generateDebugResValues UP-TO-DATE
[   +2 ms] > Task :app:generateDebugResources UP-TO-DATE
[   +9 ms] > Task :app:processDebugGoogleServices UP-TO-DATE
[  +19 ms] > Task :firebase_core:generateDebugResValues UP-TO-DATE
[   +3 ms] > Task :firebase_core:compileDebugRenderscript NO-SOURCE
[   +2 ms] > Task :firebase_core:generateDebugResources UP-TO-DATE
[  +54 ms] > Task :firebase_core:packageDebugResources UP-TO-DATE
[  +15 ms] > Task :firebase_core_web:generateDebugResValues UP-TO-DATE
[   +5 ms] > Task :firebase_core_web:compileDebugRenderscript NO-SOURCE
[   +6 ms] > Task :firebase_core_web:generateDebugResources UP-TO-DATE
[   +9 ms] > Task :firebase_core_web:packageDebugResources UP-TO-DATE
[   +3 ms] > Task :firebase_messaging:generateDebugResValues UP-TO-DATE
[   +1 ms] > Task :firebase_messaging:compileDebugRenderscript NO-SOURCE
[   +7 ms] > Task :firebase_messaging:generateDebugResources UP-TO-DATE
[   +1 ms] > Task :firebase_messaging:packageDebugResources UP-TO-DATE
[   +5 ms] > Task :shared_preferences:compileDebugRenderscript NO-SOURCE
[   +2 ms] > Task :shared_preferences:generateDebugResValues UP-TO-DATE
[   +3 ms] > Task :shared_preferences:generateDebugResources UP-TO-DATE
[   +8 ms] > Task :shared_preferences:packageDebugResources UP-TO-DATE
[   +3 ms] > Task :shared_preferences_macos:generateDebugResValues UP-TO-DATE
[   +6 ms] > Task :shared_preferences_macos:compileDebugRenderscript NO-SOURCE
[  +12 ms] > Task :shared_preferences_macos:generateDebugResources UP-TO-DATE
[   +2 ms] > Task :shared_preferences_macos:packageDebugResources UP-TO-DATE
[   +3 ms] > Task :shared_preferences_web:generateDebugResValues UP-TO-DATE
[   +6 ms] > Task :shared_preferences_web:compileDebugRenderscript NO-SOURCE
[   +2 ms] > Task :shared_preferences_web:generateDebugResources UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:packageDebugResources UP-TO-DATE
[ +192 ms] > Task :app:mergeDebugResources UP-TO-DATE
[  +10 ms] > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
[   +5 ms] > Task :firebase_core:checkDebugManifest UP-TO-DATE
[   +6 ms] > Task :firebase_core:processDebugManifest UP-TO-DATE
[   +2 ms] > Task :firebase_core_web:checkDebugManifest UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:processDebugManifest UP-TO-DATE
[   +8 ms] > Task :firebase_messaging:checkDebugManifest UP-TO-DATE
[   +2 ms] > Task :firebase_messaging:processDebugManifest UP-TO-DATE
[  +13 ms] > Task :shared_preferences:checkDebugManifest UP-TO-DATE
[   +1 ms] > Task :shared_preferences:processDebugManifest UP-TO-DATE
[   +5 ms] > Task :shared_preferences_macos:checkDebugManifest UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:processDebugManifest UP-TO-DATE
[   +5 ms] > Task :shared_preferences_web:checkDebugManifest UP-TO-DATE
[  +65 ms] > Task :shared_preferences_web:processDebugManifest UP-TO-DATE
[  +19 ms] > Task :app:processDebugManifest UP-TO-DATE
[  +11 ms] > Task :firebase_core:parseDebugLibraryResources UP-TO-DATE
[   +7 ms] > Task :firebase_core_web:parseDebugLibraryResources UP-TO-DATE
[   +6 ms] > Task :firebase_core_web:generateDebugRFile UP-TO-DATE
[  +10 ms] > Task :firebase_core:generateDebugRFile UP-TO-DATE
[   +4 ms] > Task :firebase_messaging:parseDebugLibraryResources UP-TO-DATE
[   +1 ms] > Task :firebase_messaging:generateDebugRFile UP-TO-DATE
[  +11 ms] > Task :shared_preferences:parseDebugLibraryResources UP-TO-DATE
[   +4 ms] > Task :shared_preferences_macos:parseDebugLibraryResources UP-TO-DATE
[   +4 ms] > Task :shared_preferences_web:parseDebugLibraryResources UP-TO-DATE
[  +15 ms] > Task :shared_preferences_web:generateDebugRFile UP-TO-DATE
[   +9 ms] > Task :shared_preferences_macos:generateDebugRFile UP-TO-DATE
[   +3 ms] > Task :shared_preferences:generateDebugRFile UP-TO-DATE
[   +1 ms] > Task :app:processDebugResources UP-TO-DATE
[   +8 ms] > Task :firebase_core:generateDebugBuildConfig UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:generateDebugBuildConfig UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:javaPreCompileDebug UP-TO-DATE
[  +39 ms] > Task :firebase_core_web:compileDebugJavaWithJavac UP-TO-DATE
[  +15 ms] > Task :firebase_core_web:bundleLibCompileDebug UP-TO-DATE
[  +32 ms] > Task :firebase_core:javaPreCompileDebug UP-TO-DATE
[   +2 ms] > Task :firebase_core:compileDebugJavaWithJavac UP-TO-DATE
[   +1 ms] > Task :firebase_core:bundleLibCompileDebug UP-TO-DATE
[   +3 ms] > Task :firebase_messaging:generateDebugBuildConfig UP-TO-DATE
[   +9 ms] > Task :firebase_messaging:javaPreCompileDebug UP-TO-DATE
[   +2 ms] > Task :firebase_messaging:compileDebugJavaWithJavac UP-TO-DATE
[   +5 ms] > Task :firebase_messaging:bundleLibCompileDebug UP-TO-DATE
[   +2 ms] > Task :shared_preferences:generateDebugBuildConfig UP-TO-DATE
[  +24 ms] > Task :shared_preferences_macos:generateDebugBuildConfig UP-TO-DATE
[  +10 ms] > Task :shared_preferences_macos:javaPreCompileDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:compileDebugJavaWithJavac UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:bundleLibCompileDebug UP-TO-DATE
[   +7 ms] > Task :shared_preferences_web:generateDebugBuildConfig UP-TO-DATE
[   +3 ms] > Task :shared_preferences_web:javaPreCompileDebug UP-TO-DATE
[   +7 ms] > Task :shared_preferences_web:compileDebugJavaWithJavac UP-TO-DATE
[   +2 ms] > Task :shared_preferences_web:bundleLibCompileDebug UP-TO-DATE
[   +7 ms] > Task :shared_preferences:javaPreCompileDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences:compileDebugJavaWithJavac UP-TO-DATE
[   +4 ms] > Task :shared_preferences:bundleLibCompileDebug UP-TO-DATE
[  +55 ms] > Task :app:compileDebugKotlin UP-TO-DATE
[   +7 ms] > Task :app:javaPreCompileDebug UP-TO-DATE
[   +2 ms] > Task :app:compileDebugJavaWithJavac UP-TO-DATE
[   +1 ms] > Task :app:compileDebugSources UP-TO-DATE
[  +84 ms] > Task :app:processDebugJavaRes NO-SOURCE
[   +6 ms] > Task :firebase_core:processDebugJavaRes NO-SOURCE
[   +2 ms] > Task :firebase_core:bundleLibResDebug UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:processDebugJavaRes NO-SOURCE
[   +1 ms] > Task :firebase_core_web:bundleLibResDebug UP-TO-DATE
[  +11 ms] > Task :firebase_messaging:processDebugJavaRes NO-SOURCE
[   +7 ms] > Task :firebase_messaging:bundleLibResDebug UP-TO-DATE
[   +3 ms] > Task :shared_preferences:processDebugJavaRes NO-SOURCE
[   +8 ms] > Task :shared_preferences:bundleLibResDebug UP-TO-DATE
[   +2 ms] > Task :shared_preferences_macos:processDebugJavaRes NO-SOURCE
[   +5 ms] > Task :shared_preferences_macos:bundleLibResDebug UP-TO-DATE
[   +5 ms] > Task :shared_preferences_web:processDebugJavaRes NO-SOURCE
[   +1 ms] > Task :shared_preferences_web:bundleLibResDebug UP-TO-DATE
[   +5 ms] > Task :app:mergeDebugJavaResource UP-TO-DATE
[   +2 ms] > Task :shared_preferences_macos:bundleLibRuntimeDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:createFullJarDebug UP-TO-DATE
[   +8 ms] > Task :shared_preferences_web:bundleLibRuntimeDebug UP-TO-DATE
[  +52 ms] > Task :shared_preferences_web:createFullJarDebug UP-TO-DATE
[  +64 ms] > Task :shared_preferences:bundleLibRuntimeDebug UP-TO-DATE
[  +51 ms] > Task :shared_preferences:createFullJarDebug UP-TO-DATE
[  +39 ms] > Task :firebase_messaging:bundleLibRuntimeDebug UP-TO-DATE
[  +31 ms] > Task :firebase_messaging:createFullJarDebug UP-TO-DATE
[  +23 ms] > Task :firebase_core_web:bundleLibRuntimeDebug UP-TO-DATE
[  +16 ms] > Task :firebase_core_web:createFullJarDebug UP-TO-DATE
[   +1 ms] > Task :firebase_core:bundleLibRuntimeDebug UP-TO-DATE
[   +1 ms] > Task :firebase_core:createFullJarDebug UP-TO-DATE
[   +4 ms] > Task :app:checkDebugDuplicateClasses UP-TO-DATE
[   +2 ms] > Task :app:desugarDebugFileDependencies UP-TO-DATE
[   +3 ms] > Task :app:mergeExtDexDebug UP-TO-DATE
[  +37 ms] > Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE
[  +10 ms] > Task :app:mergeDexDebug UP-TO-DATE
[   +3 ms] > Task :app:validateSigningDebug UP-TO-DATE
[   +1 ms] > Task :app:signingConfigWriterDebug UP-TO-DATE
[   +1 ms] > Task :app:mergeDebugJniLibFolders UP-TO-DATE
[   +1 ms] > Task :firebase_core:mergeDebugJniLibFolders UP-TO-DATE
[  +74 ms] > Task :firebase_core:mergeDebugNativeLibs UP-TO-DATE
[   +4 ms] > Task :firebase_core:stripDebugDebugSymbols UP-TO-DATE
[   +3 ms] > Task :firebase_core:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:mergeDebugJniLibFolders UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:mergeDebugNativeLibs UP-TO-DATE
[  +10 ms] > Task :firebase_core_web:stripDebugDebugSymbols UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
[   +7 ms] > Task :firebase_messaging:mergeDebugJniLibFolders UP-TO-DATE
[   +1 ms] > Task :firebase_messaging:mergeDebugNativeLibs UP-TO-DATE
[   +1 ms] > Task :firebase_messaging:stripDebugDebugSymbols UP-TO-DATE
[   +2 ms] > Task :firebase_messaging:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences:mergeDebugJniLibFolders UP-TO-DATE
[   +7 ms] > Task :shared_preferences:mergeDebugNativeLibs UP-TO-DATE
[   +1 ms] > Task :shared_preferences:stripDebugDebugSymbols UP-TO-DATE
[  +10 ms] > Task :shared_preferences:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:mergeDebugJniLibFolders UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:mergeDebugNativeLibs UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:stripDebugDebugSymbols UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:mergeDebugJniLibFolders UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:mergeDebugNativeLibs UP-TO-DATE
[   +7 ms] > Task :shared_preferences_web:stripDebugDebugSymbols UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
[        ] > Task :app:mergeDebugNativeLibs UP-TO-DATE
[        ] > Task :app:stripDebugDebugSymbols UP-TO-DATE
[        ] Compatible side by side NDK version was not found.
[        ] > Task :app:packageDebug UP-TO-DATE
[   +1 ms] > Task :app:assembleDebug UP-TO-DATE
[   +1 ms] > Task :firebase_core:extractDebugAnnotations UP-TO-DATE
[   +8 ms] > Task :firebase_core:mergeDebugGeneratedProguardFiles UP-TO-DATE
[  +18 ms] > Task :firebase_core:mergeDebugConsumerProguardFiles UP-TO-DATE
[   +6 ms] > Task :firebase_core:prepareLintJarForPublish UP-TO-DATE
[   +2 ms] > Task :firebase_core:mergeDebugJavaResource UP-TO-DATE
[   +1 ms] > Task :firebase_core:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
[   +6 ms] > Task :firebase_core:transformNativeLibsWithSyncJniLibsForDebug UP-TO-DATE
[   +3 ms] > Task :firebase_core:bundleDebugAar UP-TO-DATE
[   +1 ms] > Task :firebase_core:compileDebugSources UP-TO-DATE
[   +1 ms] > Task :firebase_core:assembleDebug UP-TO-DATE
[   +9 ms] > Task :firebase_core_web:extractDebugAnnotations UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:mergeDebugGeneratedProguardFiles UP-TO-DATE
[   +2 ms] > Task :firebase_core_web:mergeDebugConsumerProguardFiles UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:prepareLintJarForPublish UP-TO-DATE
[  +11 ms] > Task :firebase_core_web:mergeDebugJavaResource UP-TO-DATE
[   +2 ms] > Task :firebase_core_web:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
[   +1 ms] > Task :firebase_core_web:transformNativeLibsWithSyncJniLibsForDebug UP-TO-DATE
[   +9 ms] > Task :firebase_core_web:bundleDebugAar UP-TO-DATE
[   +2 ms] > Task :firebase_core_web:compileDebugSources UP-TO-DATE
[   +4 ms] > Task :firebase_core_web:assembleDebug UP-TO-DATE
[   +2 ms] > Task :firebase_messaging:extractDebugAnnotations UP-TO-DATE
[   +4 ms] > Task :firebase_messaging:mergeDebugGeneratedProguardFiles UP-TO-DATE
[  +11 ms] > Task :firebase_messaging:mergeDebugConsumerProguardFiles UP-TO-DATE
[   +5 ms] > Task :firebase_messaging:prepareLintJarForPublish UP-TO-DATE
[   +7 ms] > Task :firebase_messaging:mergeDebugJavaResource UP-TO-DATE
[  +38 ms] > Task :firebase_messaging:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
[  +27 ms] > Task :firebase_messaging:transformNativeLibsWithSyncJniLibsForDebug UP-TO-DATE
[   +6 ms] > Task :firebase_messaging:bundleDebugAar UP-TO-DATE
[   +5 ms] > Task :firebase_messaging:compileDebugSources UP-TO-DATE
[   +5 ms] > Task :firebase_messaging:assembleDebug UP-TO-DATE
[   +5 ms] > Task :shared_preferences:extractDebugAnnotations UP-TO-DATE
[   +8 ms] > Task :shared_preferences:mergeDebugGeneratedProguardFiles UP-TO-DATE
[   +4 ms] > Task :shared_preferences:mergeDebugConsumerProguardFiles UP-TO-DATE
[   +3 ms] > Task :shared_preferences:prepareLintJarForPublish UP-TO-DATE
[   +8 ms] > Task :shared_preferences:mergeDebugJavaResource UP-TO-DATE
[   +5 ms] > Task :shared_preferences:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences:transformNativeLibsWithSyncJniLibsForDebug UP-TO-DATE
[   +3 ms] > Task :shared_preferences:bundleDebugAar UP-TO-DATE
[   +2 ms] > Task :shared_preferences:compileDebugSources UP-TO-DATE
[   +3 ms] > Task :shared_preferences:assembleDebug UP-TO-DATE
[   +3 ms] > Task :shared_preferences_macos:extractDebugAnnotations UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:mergeDebugGeneratedProguardFiles UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:mergeDebugConsumerProguardFiles UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:prepareLintJarForPublish UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:mergeDebugJavaResource UP-TO-DATE
[   +7 ms] > Task :shared_preferences_macos:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:transformNativeLibsWithSyncJniLibsForDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:bundleDebugAar UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:compileDebugSources UP-TO-DATE
[   +1 ms] > Task :shared_preferences_macos:assembleDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:extractDebugAnnotations UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:mergeDebugGeneratedProguardFiles UP-TO-DATE
[   +8 ms] > Task :shared_preferences_web:mergeDebugConsumerProguardFiles UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:prepareLintJarForPublish UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:mergeDebugJavaResource UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:transformNativeLibsWithSyncJniLibsForDebug UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:bundleDebugAar UP-TO-DATE
[   +1 ms] > Task :shared_preferences_web:compileDebugSources UP-TO-DATE
[        ] > Task :shared_preferences_web:assembleDebug UP-TO-DATE
[   +9 ms] BUILD SUCCESSFUL in 5s
[   +1 ms] 199 actionable tasks: 3 executed, 196 up-to-date
[ +274 ms] Running Gradle task 'assembleDebug'... (completed in 5.9s)
[  +69 ms] calculateSha: LocalDirectory:
'C:\Users\USER\Desktop\flutter\test_app\test_app\build\app\outputs\apk'/app.apk
[ +115 ms] calculateSha: reading file took 108us
[+1200 ms] calculateSha: computing sha took 1196us
[  +13 ms] √ Built build\app\outputs\apk\debug\app-debug.apk.
[   +9 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\build-tools\28.0.3\aapt dump xmltree
C:\Users\USER\Desktop\flutter\test_app\test_app\build\app\outputs\apk\app.apk AndroidManifest.xml
[  +37 ms] Exit code 0 from: C:\Users\USER\AppData\Local\Android\sdk\build-tools\28.0.3\aapt dump xmltree
C:\Users\USER\Desktop\flutter\test_app\test_app\build\app\outputs\apk\app.apk AndroidManifest.xml
[   +4 ms] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
               A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
               A: package="com.example.test_app" (Raw: "com.example.test_app")
               A: platformBuildVersionCode=(type 0x10)0x1c
               A: platformBuildVersionName=(type 0x10)0x9
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: uses-permission (line=15)
                 A: android:name(0x01010003)="android.permission.ACCESS_NETWORK_STATE" (Raw:
                 "android.permission.ACCESS_NETWORK_STATE")
               E: uses-permission (line=16)
                 A: android:name(0x01010003)="android.permission.WAKE_LOCK" (Raw: "android.permission.WAKE_LOCK")
               E: uses-permission (line=17)
                 A: android:name(0x01010003)="com.google.android.c2dm.permission.RECEIVE" (Raw:
                 "com.google.android.c2dm.permission.RECEIVE")
               E: application (line=25)
                 A: android:label(0x01010001)="test_app" (Raw: "test_app")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="com.example.test_app.Application" (Raw:
                 "com.example.test_app.Application")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw:
                 "androidx.core.app.CoreComponentFactory")
                 E: activity (line=31)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.test_app.MainActivity" (Raw:
                   "com.example.test_app.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: intent-filter (line=38)
                     E: action (line=39)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=41)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw:
                       "android.intent.category.LAUNCHER")
                   E: intent-filter (line=43)
                     E: action (line=44)
                       A: android:name(0x01010003)="FLUTTER_NOTIFICATION_CLICK" (Raw: "FLUTTER_NOTIFICATION_CLICK")
                     E: category (line=46)
                       A: android:name(0x01010003)="android.intent.category.DEFAULT" (Raw:
                       "android.intent.category.DEFAULT")
                 E: meta-data (line=53)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
                 E: service (line=57)
                   A: android:name(0x01010003)="com.google.firebase.components.ComponentDiscoveryService" (Raw:
                   "com.google.firebase.components.ComponentDiscoveryService")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   A: android:directBootAware(0x01010505)=(type 0x12)0xffffffff
                   E: meta-data (line=61)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:io.flutter.plugins.firebase.core.Flutter
                     FirebaseAppRegistrar" (Raw:
                     "com.google.firebase.components:io.flutter.plugins.firebase.core.FlutterFirebaseAppRegistrar")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=64)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:io.flutter.plugins.firebasemessaging.Flu
                     tterFirebaseAppRegistrar" (Raw:
                     "com.google.firebase.components:io.flutter.plugins.firebasemessaging.FlutterFirebaseAppRegistrar"
                     )
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=67)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:com.google.firebase.messaging.FirebaseMe
                     ssagingRegistrar" (Raw:
                     "com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=70)
                     A: android:name(0x01010003)="com.google.firebase.components:com.google.firebase.iid.Registrar"
                     (Raw: "com.google.firebase.components:com.google.firebase.iid.Registrar")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=73)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:com.google.firebase.datatransport.Transp
                     ortRegistrar" (Raw:
                     "com.google.firebase.components:com.google.firebase.datatransport.TransportRegistrar")
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                   E: meta-data (line=76)
                     A:
                     android:name(0x01010003)="com.google.firebase.components:com.google.firebase.installations.Fireba
                     seInstallationsRegistrar" (Raw:
                     "com.google.firebase.components:com.google.firebase.installations.FirebaseInstallationsRegistrar"
                     )
                     A: android:value(0x01010024)="com.google.firebase.components.ComponentRegistrar" (Raw:
                     "com.google.firebase.components.ComponentRegistrar")
                 E: service (line=80)
                   A: android:name(0x01010003)="io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService"
                   (Raw: "io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService")
                   E: intent-filter (line=81)
                     E: action (line=82)
                       A: android:name(0x01010003)="com.google.firebase.MESSAGING_EVENT" (Raw:
                       "com.google.firebase.MESSAGING_EVENT")
                 E: service (line=89)
                   A: android:name(0x01010003)="com.google.firebase.messaging.FirebaseMessagingService" (Raw:
                   "com.google.firebase.messaging.FirebaseMessagingService")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   E: intent-filter (line=92)
                     A: android:priority(0x0101001c)=(type 0x10)0xfffffe0c
                     E: action (line=93)
                       A: android:name(0x01010003)="com.google.firebase.MESSAGING_EVENT" (Raw:
                       "com.google.firebase.MESSAGING_EVENT")
                 E: receiver (line=97)
                   A: android:name(0x01010003)="com.google.firebase.iid.FirebaseInstanceIdReceiver" (Raw:
                   "com.google.firebase.iid.FirebaseInstanceIdReceiver")
                   A: android:permission(0x01010006)="com.google.android.c2dm.permission.SEND" (Raw:
                   "com.google.android.c2dm.permission.SEND")
                   A: android:exported(0x01010010)=(type 0x12)0xffffffff
                   E: intent-filter (line=101)
                     E: action (line=102)
                       A: android:name(0x01010003)="com.google.android.c2dm.intent.RECEIVE" (Raw:
                       "com.google.android.c2dm.intent.RECEIVE")
                 E: provider (line=106)
                   A: android:name(0x01010003)="com.google.firebase.provider.FirebaseInitProvider" (Raw:
                   "com.google.firebase.provider.FirebaseInitProvider")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   A: android:authorities(0x01010018)="com.example.test_app.firebaseinitprovider" (Raw:
                   "com.example.test_app.firebaseinitprovider")
                   A: android:initOrder(0x0101001a)=(type 0x10)0x64
                 E: activity (line=112)
                   A: android:theme(0x01010000)=@0x1030010
                   A: android:name(0x01010003)="com.google.android.gms.common.api.GoogleApiActivity" (Raw:
                   "com.google.android.gms.common.api.GoogleApiActivity")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                 E: meta-data (line=117)
                   A: android:name(0x01010003)="com.google.android.gms.version" (Raw:
                   "com.google.android.gms.version")
                   A: android:value(0x01010024)=@0x7f060000
                 E: service (line=121)
                   A:
                   android:name(0x01010003)="com.google.android.datatransport.runtime.backends.TransportBackendDiscove
                   ry" (Raw: "com.google.android.datatransport.runtime.backends.TransportBackendDiscovery")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   E: meta-data (line=124)
                     A: android:name(0x01010003)="backend:com.google.android.datatransport.cct.CctBackendFactory"
                     (Raw: "backend:com.google.android.datatransport.cct.CctBackendFactory")
                     A: android:value(0x01010024)="cct" (Raw: "cct")
                 E: service (line=128)
                   A:
                   android:name(0x01010003)="com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfo
                   SchedulerService" (Raw:
                   "com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService")
                   A: android:permission(0x01010006)="android.permission.BIND_JOB_SERVICE" (Raw:
                   "android.permission.BIND_JOB_SERVICE")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                 E: receiver (line=134)
                   A:
                   android:name(0x01010003)="com.google.android.datatransport.runtime.scheduling.jobscheduling.AlarmMa
                   nagerSchedulerBroadcastReceiver" (Raw:
                   "com.google.android.datatransport.runtime.scheduling.jobscheduling.AlarmManagerSchedulerBroadcastRe
                   ceiver")
                   A: android:exported(0x01010010)=(type 0x12)0x0
[  +34 ms] Stopping app 'app.apk' on SM G960F.
[   +2 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 27b8a801df1c7ece shell am
force-stop com.example.test_app
[ +240 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 27b8a801df1c7ece shell pm list
packages com.example.test_app
[ +798 ms] package:com.example.test_app
[   +8 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 27b8a801df1c7ece shell cat
/data/local/tmp/sky.com.example.test_app.sha1
[  +71 ms] 02723401cd289157e3db4241c92e7775e732883e
[   +3 ms] Latest build already installed.
[   +2 ms] SM G960F startApp
[   +2 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 27b8a801df1c7ece shell am
start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling
true --ez enable-checked-mode true --ez verify-entry-points true
com.example.test_app/com.example.test_app.MainActivity
[ +130 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.test_app/.MainActivity (has
extras) }
[   +3 ms] Waiting for observatory port to be available...
[ +618 ms] Observatory URL on device: http://127.0.0.1:36497/1kwdJYYRuC4=/
[   +5 ms] executing: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 27b8a801df1c7ece forward tcp:0
tcp:36497
[  +28 ms] 55443
[   +2 ms] Forwarded host port 55443 to device port 36497 for Observatory
[  +12 ms] Connecting to service protocol: http://127.0.0.1:55443/1kwdJYYRuC4=/
[ +281 ms] Successfully connected to service protocol: http://127.0.0.1:55443/1kwdJYYRuC4=/
[   +7 ms] Sending to VM service: getVM({})
[   +8 ms] Result: {type: VM, name: vm, architectureBits: 64, hostCPU: Unknown, operatingSystem: android, targetCPU:
arm64, version: 2.7.0 (Mon Dec 2 20:10:59 2019 +0100) on "android_arm64", _profilerMode: VM, _nativeZoneMemoryUsage:
0, pid: 32321, startTime: 158714...
[   +8 ms] Sending to VM service: getIsolate({isolateId: isolates/119811508390383})
[   +7 ms] Sending to VM service: _flutter.listViews({})
[  +34 ms] Result: {type: Isolate, id: isolates/119811508390383, name: main, number: 119811508390383, _originNumber:
119811508390383, startTime: 1587140111390, _heaps: {new: {type: HeapSpace, name: new, vmName: Scavenger, collections:
0, avgCollectionPeriodMillis: 0...
[  +20 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0x76a1c57d20, isolate: {type:
@Isolate, fixedId: true, id: isolates/119811508390383, name: main.dart$main-119811508390383, number:
119811508390383}}]}
[  +10 ms] DevFS: Creating new filesystem on the device (null)
[   +2 ms] Sending to VM service: _createDevFS({fsName: test_app})
[   +6 ms] I/flutter (32321): Rebuild MyApp
[  +33 ms] Result: {type: FileSystem, name: test_app, uri:
file:///data/user/0/com.example.test_app/code_cache/test_appAYKEOI/test_app/}
[   +3 ms] DevFS: Created new filesystem on the device
(file:///data/user/0/com.example.test_app/code_cache/test_appAYKEOI/test_app/)
[   +4 ms] Updating assets
[  +92 ms] Syncing files to device SM G960F...
[   +5 ms] Scanning asset files
[   +4 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[  +13 ms] C:\src\flutter\bin\cache\dart-sdk\bin\dart.exe
C:\src\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
C:\src\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --target=flutter
-Ddart.developer.causal_async_stacks=true --output-dill
C:\Users\USER\AppData\Local\Temp\flutter_tool.96894bd3-80c6-11ea-bf41-fcf8ae96475d\app.dill --packages
C:\Users\USER\Desktop\flutter\test_app\test_app\.packages -Ddart.vm.profile=false -Ddart.vm.product=false
--bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,av
oid-closure-call-instructions --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root
[  +10 ms] <- compile package:test_app/main.dart
[+3730 ms] I/flutter (32321): Pressed button 1
[+2545 ms] Updating files
[ +269 ms] DevFS: Sync finished
[   +4 ms] Syncing files to device SM G960F... (completed in 6,581ms, longer than expected)
[   +2 ms] Synced 0.9MB.
[   +2 ms] Sending to VM service: _flutter.listViews({})
[   +7 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0x76a1c57d20, isolate: {type:
@Isolate, fixedId: true, id: isolates/119811508390383, name: main.dart$main-119811508390383, number:
119811508390383}}, {type: FlutterView, id: _flutterView/0x76a1c59220, isolate: {type: @Isolate, fixedId: true, id:
isolates/1815767142308407, name: main.dart$main-1815767142308407, number: 1815767142308407}}]}
[   +2 ms] Sending to VM service: getIsolate({isolateId: isolates/1815767142308407})
[   +2 ms] <- accept
[   +6 ms] Connected to _flutterView/0x76a1c57d20.
[   +1 ms] Connected to _flutterView/0x76a1c59220.
[   +2 ms] 🔥  To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
[   +8 ms] An Observatory debugger and profiler on SM G960F is available at: http://127.0.0.1:55443/1kwdJYYRuC4=/
[   +1 ms] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
[  +59 ms] Result: {type: Isolate, id: isolates/1815767142308407, name: main, number: 1815767142308407, _originNumber:
1815767142308407, startTime: 1587140112466, _heaps: {new: {type: HeapSpace, name: new, vmName: Scavenger, collections:
0, avgCollectionPeriodMillis...
[+3366 ms] I/flutter (32321): Sent notification
[  +26 ms] I/flutter (32321): >>> onMessage
[   +3 ms] I/flutter (32321): >>> Got notification with action 1
[   +4 ms] I/flutter (32321): >>> navigatorKey.currentState = NavigatorState#111ba(tickers: tracking 1 ticker)
[   +1 ms] I/flutter (32321): >>> providerKey.currentState = MyProviderState#57bd8
[   +3 ms] I/flutter (32321): >>> You are lucky! The app is in foreground or the user clicked the notification.
[   +5 ms] I/flutter (32321): >>> You can update the UI or navigate to inform the user of the notification.
[   +1 ms] I/flutter (32321): >>> trying to increment counter1 from 0 to 1
[        ] I/flutter (32321): >>> trying to increment counter2
[   +4 ms] I/flutter (32321): >>> trying to increment counter3
[   +3 ms] I/flutter (32321): >>> onMessage
[   +1 ms] I/flutter (32321): >>> Got notification with action 1
[   +1 ms] I/flutter (32321): >>> navigatorKey.currentState = NavigatorState#111ba(tickers: tracking 1 ticker)
[   +1 ms] I/flutter (32321): >>> providerKey.currentState = MyProviderState#57bd8
[   +3 ms] I/flutter (32321): >>> You are lucky! The app is in foreground or the user clicked the notification.
[   +4 ms] I/flutter (32321): >>> You can update the UI or navigate to inform the user of the notification.
[   +1 ms] I/flutter (32321): >>> trying to increment counter1 from 1 to 2
[   +1 ms] I/flutter (32321): >>> trying to increment counter2
[   +3 ms] I/flutter (32321): >>> trying to increment counter3
[+6273 ms] I/flutter (32321): Pressed button 2
[+5714 ms] I/flutter (32321): Sent notification
[ +120 ms] I/flutter (32321): >>> onMessage
[   +6 ms] I/flutter (32321): >>> Got notification with action 2
[   +1 ms] I/flutter (32321): >>> navigatorKey.currentState = NavigatorState#111ba(tickers: tracking 1 ticker)
[   +1 ms] I/flutter (32321): >>> providerKey.currentState = MyProviderState#57bd8
[   +1 ms] I/flutter (32321): >>> You are lucky! The app is in foreground or the user clicked the notification.
[   +3 ms] I/flutter (32321): >>> You can update the UI or navigate to inform the user of the notification.
[   +3 ms] I/flutter (32321): >>> trying to increment counter1 from 2 to 3
[   +1 ms] I/flutter (32321): >>> trying to increment counter2
[   +1 ms] I/flutter (32321): >>> trying to increment counter3
[   +4 ms] I/flutter (32321): >>> onMessage
[   +3 ms] I/flutter (32321): >>> Got notification with action 2
[   +1 ms] I/flutter (32321): >>> navigatorKey.currentState = NavigatorState#111ba(tickers: tracking 1 ticker)
[   +1 ms] I/flutter (32321): >>> providerKey.currentState = MyProviderState#57bd8
[        ] I/flutter (32321): >>> You are lucky! The app is in foreground or the user clicked the notification.
[   +1 ms] I/flutter (32321): >>> You can update the UI or navigate to inform the user of the notification.
[   +7 ms] I/flutter (32321): >>> trying to increment counter1 from 3 to 4
[   +1 ms] I/flutter (32321): >>> trying to increment counter2
[   +1 ms] I/flutter (32321): >>> trying to increment counter3
[+2276 ms] I/flutter (32321): Pressed button 2
[+5697 ms] I/flutter (32321): Sent notification
[ +118 ms] I/flutter (32321): >>> onBackgroundMessage
[  +16 ms] I/flutter (32321): >>> Got notification with action 2
[   +8 ms] I/flutter (32321): >>> navigatorKey.currentState = null
[   +2 ms] I/flutter (32321): >>> providerKey.currentState = null
[   +3 ms] I/flutter (32321): >>> You are helpless! onBackgroundMessage was triggered but there is nothing you can do
to inform the user.
[   +1 ms] I/flutter (32321): >>> trying to increment counter1 from 0 to 1
[   +3 ms] I/flutter (32321): >>> trying to increment counter2
[  +13 ms] I/flutter (32321): >>> Error: <<NoSuchMethodError: The method 'increment' was called on null.
[   +1 ms] I/flutter (32321): Receiver: null
[   +3 ms] I/flutter (32321): Tried calling: increment()>>
[   +4 ms] I/flutter (32321): >>> trying to increment counter3
[  +20 ms] I/flutter (32321): >>> Error: <<MissingPluginException(No implementation found for method getAll on channel
plugins.flutter.io/shared_preferences)>>
LtotheWT commented 4 years ago

my android project is in kotlin, need documentation to setup in kotlin for handle background messages

dvdlg commented 4 years ago

Anyone knows how to solve it? I'm strugling with it over 2 weeks

Errechydy commented 4 years ago

@dvdlg I'm having the same problem. Do you get notification if the app is closed?

dvdlg commented 4 years ago

@Errechydy , as you can see in my my flutter run --verbose, if the app is closed onBackgroundMessage is triggered, but nothing else happens

dvdlg commented 4 years ago

@TahaTesser, @Ehesp, Is it such a complex question? It should be basic...

Errechydy commented 4 years ago

@dvdlg yes but do you get that notification on your phone, like does your phone ring and display notification title and body if the app is terminated?

dvdlg commented 4 years ago

@Errechydy no

Errechydy commented 4 years ago

@dvdlg Why is that? i mean getting notification when the app is terminated should be the main focus of those who are behind this plugin. if the user is using the app then the getting a notification is not that important

dvdlg commented 4 years ago

I don't know. As you can see, I am confused as well about how to use it. I thought that once I'm able to trigger onBackgroundMessage I could do what I want, but the only thing that works is to print to the console. BTW, onBackgroundMessage is triggered only if you drop the title and body from the json. If you keep them, onResume will be triggered and then you will see your phone ring and display notification title and body if the app is terminated. But then I can read the notification only when I tap the notification itself, not if I resume to the app in a different way.

Errechydy commented 4 years ago

@dvdlg I'm not sure if i get what you're saying, when you terminate your app do you get notifications? like does your phone ring. In my case i get notifications (my phone ring) only when my app is still running, if i swipe the app (terminate it) i do not get notification at all, i send them and i wait for like hours just to see if they will popup but nothing, if i want to get a notification i have to open the app. does your app do the same or you get notification when you terminate your app?

dvdlg commented 4 years ago

@Errechydy, sorry for misleading you. My phone does ring even if the app is totaly terminated, only in the case that the notification was sent with body and title. in that case onResume and onLaunch are triggered once I tap the notification. but not if I resume to the app by taping the app itself. If I send a message without a body and title, it doesn't ring.

could it be that you don't send the message correctly? try to send it from a different app or from a different phone, or from firebase dashboard

dvdlg commented 4 years ago

@Errechydy, wew you able to trigger the onBackgroundMessage callback? and if you did, were you able to do there anything that is not printing to the console?

Errechydy commented 4 years ago

@dvdlg seems like my problem was the phone manufacture, when the app is terminated they don't allow it's notifications. they whitelist only big apps like Whatsapp or Facebook ... I was able to trigger the onBackgroundMessage callback but like you said you can't do anything except printing to the console. i tried to store the notification data to the local database but it gives me this:

I/flutter (18495): Unable to handle incoming background message.
I/flutter (18495): NoSuchMethodError: The method 'insert' was called on null.
I/flutter (18495): Receiver: null
mostafa5731 commented 4 years ago

hi guys there may be interference with another lib, for example it is possible to have the following error due to the lib KeyboardVisibility or location

dvdlg commented 4 years ago

@mostafa5731 , I opened a clean project for the sake of this example. You can see the code that I published, it has no other libs. Can you provide a working code example?

mostafa5731 commented 4 years ago

@mostafa5731 , I opened a clean project for the sake of this example. You can see the code that I published, it has no other libs. Can you provide a working code example?

see this https://github.com/FirebaseExtended/flutterfire/issues/2387#issuecomment-620517797

mostafa5731 commented 4 years ago

@mostafa5731 , I opened a clean project for the sake of this example. You can see the code that I published, it has no other libs. Can you provide a working code example?

see this https://medium.com/@sylvainduch/firebase-messaging-catch-them-all-3f9c594734d7

dvdlg commented 4 years ago

@mostafa5731 , thank you very much for your answer, but unfortunately, it didn't work. When I tried to follow the steps in the link that you sent I got:

ERROR: MissingPluginException(No implementation found for method show on channel dexterous.com/flutter/local_notifications)

moreover, this solution doesn't seem to answer my question. I want to display to the user how many messages he has got so far. For this I need to somehow change the app's state (change a global variable or the disk memory or anything), but it seems that background code cannot handle such thing. I would be fine with onResume (without onBackgroundMessage) if it could be triggered when the user resumes to the app without tapping the notification.

wesQ3 commented 4 years ago

I have this issue as well. An example of how to get data back from the background isolate to the main app's isolate would be very helpful. The current documentation of // do other work really leaves out an important concept.

Yirmeyah-d commented 4 years ago

Has anyone successfully handle on backgroud notification with OnBackgroundMessage?

Fbrusca commented 4 years ago

@dvdlg

@mostafa5731 , thank you very much for your answer, but unfortunately, it didn't work. When I tried to follow the steps in the link that you sent I got:

ERROR: MissingPluginException(No implementation found for method show on channel dexterous.com/flutter/local_notifications)

moreover, this solution doesn't seem to answer my question. I want to display to the user how many messages he has got so far. For this I need to somehow change the app's state (change a global variable or the disk memory or anything), but it seems that background code cannot handle such thing. I would be fine with onResume (without onBackgroundMessage) if it could be triggered when the user resumes to the app without tapping the notification.

class YourApplication : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    override fun registerWith(registry: PluginRegistry) {
        CustomPluginRegistrant.registerWith(registry)
    }
}
class CustomPluginRegistrant {
    companion object {
        fun registerWith(registry: PluginRegistry) {
            if (alreadyRegisteredWith(registry)) {
                return
            }
            FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
            FlutterLocalNotificationsPlugin.registerWith(registry.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"));
        }

        fun alreadyRegisteredWith(registry: PluginRegistry): Boolean {
            val key: String = FirebaseCloudMessagingPluginRegistrant::class.java.getCanonicalName()
            if (registry.hasPlugin(key)) {
                return true
            }
            registry.registrarFor(key)
            return false
        }
    }
}
Yirmeyah-d commented 4 years ago

@dvdlg Hi, i had found a solution for this issue yesterday... You should know that backgroundMessage Handler Method handle only Data message, this mean your message should not the message that your sending should have this structure : { "message":{ "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "data":{ "Nick" : "Mario", "body" : "great match!", "Room" : "PortugalVSDenmark" } } } You should not put notification in it

Yirmeyah-d commented 4 years ago

Take a look at my stackoverflow post https://stackoverflow.com/questions/61827613/firebase-messaging-onbackgroundmessage-not-handling-notification-when-app-is-on

franco-brusca commented 4 years ago

Take a look at my stackoverflow post https://stackoverflow.com/questions/61827613/firebase-messaging-onbackgroundmessage-not-handling-notification-when-app-is-on

In my case the operation is totally inconsistent. Sometimes it works and sometimes I just get the message "Service took too long to process intent: com.google.android.c2dm.intent.RECEIVE App may get closed".

Yirmeyah-d commented 4 years ago

Take a look at my stackoverflow post https://stackoverflow.com/questions/61827613/firebase-messaging-onbackgroundmessage-not-handling-notification-when-app-is-on

In my case the operation is totally inconsistent. Sometimes it works and sometimes I just get the message "Service took too long to process intent: com.google.android.c2dm.intent.RECEIVE App may get closed".

Oh really ? For me it's working every time, maybe your're missing something in your AndroidManifest.xml

Fbrusca commented 4 years ago

Take a look at my stackoverflow post https://stackoverflow.com/questions/61827613/firebase-messaging-onbackgroundmessage-not-handling-notification-when-app-is-on

In my case the operation is totally inconsistent. Sometimes it works and sometimes I just get the message "Service took too long to process intent: com.google.android.c2dm.intent.RECEIVE App may get closed".

Oh really ? For me it's working every time, maybe your're missing something in your AndroidManifest.xml

I have found the solution integrating this branch #1917

dvdlg commented 3 years ago

@Fbrusca, the solution that you suggested is already part of my code. So if it works for you, it means that there is something else that you do that I missed. Let me explain again what I'm trying to do, I want to present to the user a list of all past messages. For start I am trying to show only the number of messages.

@Yirmerah, about the Data messages vs Notifications, you can see in the code that I posted that I already took care of it and tried both options. About your stakoverflow post, what is showNotificationMediaStyle and why does it work in background while all my attempts to do anything in background failed?

For now, nobody has yet solved my problem. It seems that onBackgroundMessage is a useless tool. If you think that I am wrong, please provide a way to present a list of all messages the user has ever got.

oskara commented 3 years ago

Finally I got something working! I ended up using a named ReceivePort.

Here is what I did in main.dart:

final ReceivePort backgroundMessageport = ReceivePort();
const String backgroundMessageIsolateName = 'fcm_background_msg_isolate';

Future<dynamic> backgroundMessageHandler(Map<String, dynamic> message) async {
  if (message.containsKey('data')) {
    final port = IsolateNameServer.lookupPortByName(backgroundMessageIsolateName);
    port.send(message);
  }
}

void backgroundMessagePortHandler(message) {
  final dynamic data = message['data'];

  // Here I can access and update my top-level variables.
}

void main() {
 ...

 IsolateNameServer.registerPortWithName(
   backgroundMessageport.sendPort,
   backgroundMessageIsolateName,
 );

 backgroundMessageport.listen(backgroundMessagePortHandler);

 runApp(...)
}

Not sure if this violates Flutter or/and the isolate pattern and I would be happy to get input on this!

d4-t commented 3 years ago

@dvdlg I met the same problem, plugins did not work with background message handler, solved by adding plugin registration in Application.kt /Application.java

Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async { FlutterAppBadger.updateBadgeCount(1); }

Application.kt ` package com.example.myapp

import io.flutter.app.FlutterApplication import io.flutter.plugin.common.PluginRegistry import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService import fr.g123k.flutterappbadger.FlutterAppBadgerPlugin

class Application : FlutterApplication(), PluginRegistrantCallback { @Override override fun onCreate() { super.onCreate() FlutterFirebaseMessagingService.setPluginRegistrant(this) }

   @Override
   override fun registerWith(registry: PluginRegistry) { 
    io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
    fr.g123k.flutterappbadger.FlutterAppBadgerPlugin.registerWith(registry?.registrarFor("fr.g123k.flutterappbadger.FlutterAppBadgerPlugin"));
   }

}`

iAmJay7 commented 3 years ago

how do i check its working ? i was using shared preference increment counter when get notification while app is closed but its not working

iAmJay7 commented 3 years ago

Finally I got something working! I ended up using a named ReceivePort.

Here is what I did in main.dart:

final ReceivePort backgroundMessageport = ReceivePort();
const String backgroundMessageIsolateName = 'fcm_background_msg_isolate';

Future<dynamic> backgroundMessageHandler(Map<String, dynamic> message) async {
  if (message.containsKey('data')) {
    final port = IsolateNameServer.lookupPortByName(backgroundMessageIsolateName);
    port.send(message);
  }
}

void backgroundMessagePortHandler(message) {
  final dynamic data = message['data'];

  // Here I can access and update my top-level variables.
}

void main() {
 ...

 IsolateNameServer.registerPortWithName(
   backgroundMessageport.sendPort,
   backgroundMessageIsolateName,
 );

 backgroundMessageport.listen(backgroundMessagePortHandler);

 runApp(...)
}

Not sure if this violates Flutter or/and the isolate pattern and I would be happy to get input on this!

not working for me , can you share sample project ?

CoderJava commented 3 years ago

Finally I got something working! I ended up using a named ReceivePort.

Here is what I did in main.dart:

final ReceivePort backgroundMessageport = ReceivePort();
const String backgroundMessageIsolateName = 'fcm_background_msg_isolate';

Future<dynamic> backgroundMessageHandler(Map<String, dynamic> message) async {
  if (message.containsKey('data')) {
    final port = IsolateNameServer.lookupPortByName(backgroundMessageIsolateName);
    port.send(message);
  }
}

void backgroundMessagePortHandler(message) {
  final dynamic data = message['data'];

  // Here I can access and update my top-level variables.
}

void main() {
 ...

 IsolateNameServer.registerPortWithName(
   backgroundMessageport.sendPort,
   backgroundMessageIsolateName,
 );

 backgroundMessageport.listen(backgroundMessagePortHandler);

 runApp(...)
}

Not sure if this violates Flutter or/and the isolate pattern and I would be happy to get input on this!

Your code it's working fully when my app is in background mode but, when terminated it's not working for access and update top-level variables.

CoderJava commented 3 years ago

Finally. I found solution in here. https://github.com/FirebaseExtended/flutterfire/issues/199#issuecomment-663099423

wesQ3 commented 3 years ago

I was troubleshooting a user issue when I realized that it actually was this same SendPort issue. I don't think you can pass messages through a SendPort to the foreground isolate if Android has terminated (not force-killed) your app.

I added logging to FlutterFirebaseMessagingService.java to confirm this, that the main isolate does not start and thus can't receive a message from the background SendPort:

07-31 08:25:29.990 18534 18534 D FlutterFcmService: onCreate: service init complete
07-31 08:25:29.991 18534 18534 D FlutterFcmService: onCreate: bg isolate is not running yet
07-31 08:25:30.001 18534 18534 D FlutterFcmService: startBgI: bg isolate starting
07-31 08:25:30.133 18534 18534 D FlutterFcmService: startBgI: bg isolate started with backgroundFlutterView
07-31 08:25:30.134 18534 18534 D FlutterFcmService: onCreate: bg isolate started
07-31 08:25:30.146 18534 18569 D FlutterFcmService: oMR: application is NOT in foreground
07-31 08:25:30.146 18534 18569 D FlutterFcmService: oMR: bg isolate is not running yet, queue message
07-31 08:25:43.720 18534 18534 D FlutterFcmService: onInit: bg isolate marked as running
07-31 08:25:43.720 18534 18534 D FlutterFcmService: onInit: clear messages already queued
07-31 08:25:43.721 18534 18534 D FlutterFcmService: onInit: handle queued message
07-31 08:25:43.721 18534 18534 D FlutterFcmService: executeDartCallbackInBackgroundIsolate
07-31 08:25:43.721 18534 18534 D FlutterFcmService: invoke background message handler
07-31 08:25:43.722 18534 18534 D FlutterFcmService: onInit: backgroundMessageQueue cleared
07-31 08:25:43.729 18534 18559 I flutter : No port found in lookup on IsolateNameServer! 
yourshinsuke commented 3 years ago

@dvdlg you can't it use error if you don't use static method.

E/flutter (28060): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Invalid argument(s): Failed to setup background message handler! `onBackgroundMessage`
E/flutter (28060):           should be a TOP-LEVEL OR STATIC FUNCTION and should NOT be tied to a
E/flutter (28060):           class or an anonymous function.
shinriyo commented 3 years ago

@Fbrusca Thank you. but I hope full code with import.

shinriyo commented 3 years ago

What is FirebaseCloudMessagingPluginRegistrant? Original class?

I found https://stackoverflow.com/questions/59446933/pluginregistry-cannot-be-converted-to-flutterengine/59490722#59490722

https://qastack.jp/programming/59446933/pluginregistry-cannot-be-converted-to-flutterengine

shinriyo commented 3 years ago

Not receive onBackgroundMessage.

shinriyo commented 3 years ago

@oskara not work. you don't use onBackgroundMessage?

shinriyo commented 3 years ago

onBackgroundMessage can only detect if JSON's notification is nullfrom Firebase Cloud Messaging. hm.. I guess channel id is required for Head-up notification. and channel_id is not need in the notification? why?

naveenkumardot25 commented 3 years ago

I solved this issue

https://github.com/FirebaseExtended/flutterfire/issues/2777#issuecomment-685805903

Pavel-Gorokhov commented 3 years ago

https://github.com/FirebaseExtended/flutterfire/issues/199#issuecomment-663099423

Check this out. My problem was because i didn't register in Application.java plugins, which should run in background. And now it works on Xiaomi.

91priyansh commented 3 years ago

I have this issue as well. An example of how to get data back from the background isolate to the main app's isolate would be very helpful. The current documentation of // do other work really leaves out an important concept.

I am also facing this issue..i have changed global variable value in background method and when app resumes i again change global variable value. But it's restore the value that assign into background method

91priyansh commented 3 years ago

Finally I got something working! I ended up using a named ReceivePort.

Here is what I did in main.dart:

final ReceivePort backgroundMessageport = ReceivePort();
const String backgroundMessageIsolateName = 'fcm_background_msg_isolate';

Future<dynamic> backgroundMessageHandler(Map<String, dynamic> message) async {
  if (message.containsKey('data')) {
    final port = IsolateNameServer.lookupPortByName(backgroundMessageIsolateName);
    port.send(message);
  }
}

void backgroundMessagePortHandler(message) {
  final dynamic data = message['data'];

  // Here I can access and update my top-level variables.
}

void main() {
 ...

 IsolateNameServer.registerPortWithName(
   backgroundMessageport.sendPort,
   backgroundMessageIsolateName,
 );

 backgroundMessageport.listen(backgroundMessagePortHandler);

 runApp(...)
}

Not sure if this violates Flutter or/and the isolate pattern and I would be happy to get input on this!

@oskara this is working when app is minimized but when app is terminated that time it is not working and giving this error

I/flutter ( 2017): Unable to handle incoming background message. I/flutter ( 2017): NoSuchMethodError: The method 'send' was called on null. I/flutter ( 2017): Receiver: null I/flutter ( 2017): Tried calling: send()

I think this is happening because when app is terminated so main will not run and isolate will not register with name this it is giving error do you know how to solve this problem?

Joezzy commented 3 years ago

@dvdlg Hi, i had found a solution for this issue yesterday... You should know that backgroundMessage Handler Method handle only Data message, this mean your message should not the message that your sending should have this structure : { "message":{ "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "data":{ "Nick" : "Mario", "body" : "great match!", "Room" : "PortugalVSDenmark" } } } You should not put notification in it

THIS WORKED FOR ME.....BEEN BATTLING THIS FOR DAYS NOW...THANKS YOU ARE MVP

lionuncle commented 3 years ago

This issue has been fixed since the latest update.

Screenshot 1442-07-24 at 1 42 02 AM
louis030195 commented 3 years ago

Updating firebase_messaging from 9.0.0 to 9.1.0 fixed the issue for me I had with notifications (nothing would happen).

I still have this at the app boot, but otherwise everything works fine:

E/flutter (18495): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Null check operator used on a null value E/flutter (18495): #0 MethodChannelFirebaseMessaging.registerBackgroundMessageHandler (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:173:53) E/flutter (18495): #1 FirebaseMessagingPlatform.onBackgroundMessage= (package:firebase_messaging_platform_interface/src/platform_interface/platform_interface_messaging.dart:108:16) E/flutter (18495): #2 FirebaseMessaging.onBackgroundMessage (package:firebase_messaging/src/messaging.dart:98:31)

charllyson commented 3 years ago

Estou utilizando um arquivo separado e inicializando ele na página home mas meu BackgroundMessage não funciona, como você implementou isto @louis030195 ?


@override void initState() { super.initState(); PushNotificationConfigure().configure(); }

import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';

class PushNotificationConfigure { final FirebaseMessaging _fcm = FirebaseMessaging.instance;

Future configure() async { await _fcm.requestPermission( alert: true, announcement: false, badge: true, carPlay: false, criticalAlert: false, provisional: false, sound: true, );

await _fcm.setForegroundNotificationPresentationOptions(
  alert: true,
  badge: true,
  sound: true,
);

///Recebendo mensagens quando a tela estiver aberta
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
  debugPrint('onMessage: ${message.data}');

  if (message.notification != null) {
    debugPrint(
        'onMessage contained: ${message.notification.body}');
  }
});

FirebaseMessaging.onMessageOpenedApp.listen((message) {
  debugPrint('onMessageOpenedApp: ${message.data}');

  if (message.notification != null) {
    debugPrint(
        'onMessageOpenedApp contained: ${message.notification.body}');
  }
});

FirebaseMessaging.onBackgroundMessage((message) {
  debugPrint('onBackgroundMessage: ${message.data}');

  if (message.notification != null) {
    debugPrint(
        'onBackgroundMessage contained: ${message.notification.body}');
  }
  return;
});

} }