我正在使用Flutter开发应用程序。
要使用flutter_local_notifications软件包显示通知,
我收到通知,但计划通知不起作用。
在这里How do I schedule a notification in Flutter?提出了类似的问题,但是我的接收者已经在application
标签内。
这是我的清单
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.folk.gayatrimonitor">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="gayatri_monitor"
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>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
答案 0 :(得分:0)
我遇到了同样的问题,但是无法在线找到解决方案,但是,后来我确实确定运行flutter clean
,然后flutter run
似乎对我有用。
您必须从本质上清理构建并重新构建。希望有帮助。
答案 1 :(得分:0)
在清单中添加此内部应用程序可能会解决您的问题
<service android:name="com.folk.localnotifications.services.LocalNotificationsService"
android:exported="false" />
请记住:com.folk仅用于此项目。对于其他项目,请转到清单,查看包名称并进行相应的编辑。
答案 2 :(得分:0)
我遇到了同样的问题,我通过为我发出的每个Android通知创建一个单独的通知渠道来解决了这个问题,即使它们具有相同的优先级。