Flutter
.在点击通知栏中接收到的消息时无法打开应用,但是当两个及以上消息重叠时就可以打开应用。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="testtest">

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:node="remove" tools:ignore="QueryAllPackagesPermission" />

    <uses-permission
        android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
        tools:node="remove" />
    <uses-permission
        android:name="android.permission.READ_PHONE_STATE"
        tools:node="remove" />

    <application
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:label="DiStar GPS"
        android:enableOnBackInvokedCallback="true"
        android:requestLegacyExternalStorage="true"
        tools:node="merge"
        android:process=":pushcore">

        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:exported="true"
            android:enabled="true"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize"
            android:screenOrientation="portrait"
            android:process=":pushcore">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <receiver
            android:name=".MainActivity"
            android:enabled="true" 
            android:exported="false" 
            android:process=":pushcore">
            <intent-filter>
                <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
                <category android:name="testtest" />
            </intent-filter>
        </receiver>
        <service
            android:name="cn.jpush.android.service.PushService"
            android:enabled="true"
            android:exported="false"
            android:process=":pushcore"
            tools:replace="android:exported">
            <intent-filter>
                <action android:name="cn.jpush.android.intent.REGISTER" />
                <action android:name="cn.jpush.android.intent.REPORT" />
                <action android:name="cn.jpush.android.intent.PushService" />
                <action android:name="cn.jpush.android.intent.PUSH_TIME" />
            </intent-filter>
        </service>
    </application>

    <queries>

        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>

        <intent>
            <action android:name="android.intent.action.DIAL" />
            <data android:scheme="tel" />
        </intent>

        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="*/*" />
        </intent>
    </queries>
</manifest>
Future<void> _handleNotification(
      Map<String, dynamic> message, BuildContext context) async {
    WakelockPlus.toggle(enable: true);

    try {
      debugPrint("Received notification message: $message");
      final extras = message['extras'];
      debugPrint("Extras: $extras");

      final extraData = extras['cn.jpush.android.EXTRA'];
      final dataJson = jsonDecode(extraData);
      debugPrint("Decoded dataJson: $dataJson");

      final idJson = jsonDecode(dataJson['data'] ?? {});
      debugPrint("Decoded idJson: $idJson");

      final alarm = AlarmNotiToAlarmReportHelper(idJson);
      final provider = InitProvider.initNoListen(context);
      final cars = provider.realCarModelList;
      final realSelect =
          SelectRealCarCollapseModel(list: cars, carID: alarm.devID);
      final alarmConvert = AlarmReportModel(dataMap: alarm.fromNotiConvert);

      pushToPage(context,
          page: MapHelper(
              google: AlarmReportMap(
                alarmReportModel: alarmConvert,
                realCar: realSelect.realCar ??
                    RealAndCarCollapseModel(
                        realCarBean: RealModel(cars: {}),
                        carGroupBean: CarGroupModel(cars: {})),
              ),
              here: AlarmReportHereMap(
                alarmReportModel: alarmConvert,
                realCar: realSelect.realCar ??
                    RealAndCarCollapseModel(
                        realCarBean: RealModel(cars: {}),
                        carGroupBean: CarGroupModel(cars: {})),
              )).fromSetting(context));
    } catch (e) {
      debugPrint("Error processing notification data: $e");
    }
  }

  Future<void> initPlatformState(BuildContext context) async {
    await _initializeJPush();

    try {
      _jpush.addEventHandler(
        onReceiveNotification: (message) async {
          debugPrint("onReceiveNotification: $message");
        },
        onOpenNotification: (message) async {
          log("onOpenNotification: $message");
          await _handleNotification(message, context);
        },
        onReceiveMessage: (message) async {
          debugPrint("onReceiveMessage: $message");
        },
        onReceiveNotificationAuthorization: (message) async {
          debugPrint("onReceiveNotificationAuthorization: $message");
        },
      );
    } on PlatformException catch (e) {
      debugPrint("PlatformException: $e");
    }

    if (!context.mounted) return;
  }