Skip to content

Commit

Permalink
fix(notifications): add new Android permissions to use Notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
vareversat committed Jan 22, 2024
1 parent 9e3b294 commit 17d3f7c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 30 deletions.
76 changes: 48 additions & 28 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.vareversat.chabo">
package="fr.vareversat.chabo">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />


<queries>
Expand All @@ -14,45 +16,63 @@
</intent>
</queries>

<application
android:label="Chabo"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:localeConfig="@xml/locales_config">
<application
android:label="Chabo"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:localeConfig="@xml/locales_config"
android:enableOnBackInvokedCallback="true">

<receiver
android:exported="false"
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver
android:exported="false"
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<receiver
android:exported="false"
android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver" />


<!-- Google Ads -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-4365376442391282~1258247323" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_slice_launcher_adaptive_fore" />

<!-- Google Ads -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-4365376442391282~1258247323"/>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_slice_launcher_adaptive_fore" />
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- 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"
/>
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"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
6 changes: 4 additions & 2 deletions lib/service/notification_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ class NotificationService {
localNotifications.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>();

return await androidImplementation?.requestNotificationsPermission() ??
false;
return (await androidImplementation?.requestNotificationsPermission() ??
false) &&
(await androidImplementation?.requestExactAlarmsPermission() ??
false);
}

return false;
Expand Down

0 comments on commit 17d3f7c

Please sign in to comment.