Skip to content

Commit

Permalink
fix: Request notification permission on android
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Feb 4, 2024
1 parent 5652707 commit 6cc2c6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/utils/background_push.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ class BackgroundPush {
}) async {
if (PlatformInfos.isIOS) {
await firebase?.requestPermission();
} else if (PlatformInfos.isAndroid) {
_flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestNotificationsPermission();
}
final clientName = PlatformInfos.clientName;
oldTokens ??= <String>{};
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/push_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Future<void> pushHelper(
ticker: l10n.unreadChats(notification.counts?.unread ?? 1),
importance: Importance.max,
priority: Priority.max,
shortcutId: notification.roomId,
fullScreenIntent: true, // To show notification popup
),
),
Expand Down Expand Up @@ -233,6 +234,7 @@ Future<void> _tryPushHelper(
channelDescription: groupName,
number: notification.counts?.unread,
category: AndroidNotificationCategory.message,
shortcutId: event.room.id,
styleInformation: messagingStyleInformation ??
MessagingStyleInformation(
person,
Expand Down

0 comments on commit 6cc2c6a

Please sign in to comment.