English 中文(简体)
软碎——如何在通知栏外显示FCM通知,就像什么。
原标题:Flutter - How to display FCM notification outside notification bar like whatsapp

我与刚果排雷中心一道执行了 flu碎的推动通知,该通知在 app子、背景和 app子关闭时非常有效。 但是,我寻求一种方式来显示我的通知,即如果你不在通知内就象在顶点上浮动(目前通知中无改动)那样,那么,什么情况会显示宽松通知。

“entertext

如你在上面图像中看到的那样,用户在装置上的彩色镜子里,另一张电灯的播音电显示。 下面是我在 flu忙中执行的内容:

   FirebaseMessaging.instance.getInitialMessage().then((message) {

            print(message);
        });
   FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {

            print(message);
        });

FirebaseMessaging.onMessage.listen((RemoteMessage message) {

            print(message);
});

我和roid体的表现如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app_name">
    <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.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
 

    <application
        android:allowBackup="false"
        android:label="app_name"
        android:icon="@mipmap/ic_launcher">
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>

        <service
            android:name="MyNavigationService"
            android:foregroundServiceType="location" >
        </service>
        <receiver
            android:name="app_name.FirebaseBroadcastReceiver"
            android:exported="false"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </receiver>

        <!--service
            android:name="app_name.java.MyFirebaseMessagingService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service-->

        <service
            android:name="app_name.service.MyFirebaseInstanceIDService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            </intent-filter>
        </service>

        <meta-data android:name="com.google.android.geo.API_KEY"
            android:value="A......"/>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id" />
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:exported="true"
            android:showWhenLocked="false"
            android:turnScreenOn="false"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
       
            <meta-data
                android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/launch_background" />
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

        </activity>
         <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

我的共和国版面:firebase_messaging:^13.0.4/code>。

最佳回答

在有人访问本页寻求解决办法的情况下,我能够围绕解决办法开展工作。 我得以通过<代码>awesome_notification在座。 它是一份当地通知,是挥霍性的,我是在我的<条码>中执行。 防火底部 因此,当有关数字出现在背景和启动现金交易协议时,将未来职能总结如下:

页: 1

void main() async{

 FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);

}

和我的<代码>-消防基地 如下:


Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  bool isAllowed = await AwesomeNotifications().isNotificationAllowed();
 if (!isAllowed) return;


  await AwesomeNotifications().createNotification(
      content: NotificationContent(
          id: -1, // -1 is replaced by a random number
          channelKey:  alerts ,
          title: message.notification.title,
          body: message.notification.body,
          bigPicture:  https://storage.googleapis.com/cms-storage-bucket/d406c736e7c4c57f5f61.png ,
          largeIcon: https://storage.googleapis.com/cms-storage-bucket/d406c736e7c4c57f5f61.png ,
          notificationLayout: NotificationLayout.BigPicture,
          payload: { notificationId :  1234567890 }),
      actionButtons: [
        NotificationActionButton(key:  REDIRECT , label:  Redirect ),

        NotificationActionButton(
            key:  REPLY ,
            label:  Reply Message ,
            requireInputText: true,
            actionType: ActionType.SilentAction
        ),
        NotificationActionButton(
            key:  DISMISS ,
            label:  Dismiss ,
            actionType: ActionType.DismissAction,
            isDangerousOption: true)
      ]
  );

}

请注意main.dart

问题回答

如果有人仍在寻求答案,该文件解决了我的问题。 后续行动: - 液压(信号频道编号)。 问题在于,如果未具体规定roid通知渠道,所有通知都将发送到杂项渠道,因此,你需要具体说明roid通知渠道,并利用文件所建议的图书馆来填写通知。 我的项目工作顺利进行。

For your information i use:

For flutter version:

Flutter 3.13.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ff5b5b5fa6 (6 weeks ago) • 2023-08-24 08:12:28 -0500
Engine • revision b20183e040
Tools • Dart 3.1.0 • DevTools 2.25.0

请允许我知道,你们是否需要帮助。 谢谢。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签