Skip to content

Commit

Permalink
TW-726 Notification no sound in iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
drminh2807 authored and hoangdat committed Oct 4, 2023
1 parent 56942b2 commit 0d08e40
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ let apnTokenKey = "apnToken"
case "getInitialNoti":
result(self?.initialNotiInfo)
self?.initialNotiInfo = nil
case "clearAll":
UIApplication.shared.applicationIconBadgeNumber = 0
let center = UNUserNotificationCenter.current()
center.removeAllDeliveredNotifications()
center.removeAllPendingNotificationRequests()
result(true)
default:
break
}
Expand Down
8 changes: 8 additions & 0 deletions lib/utils/background_push.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ class BackgroundPush {
"aps": {
"mutable-content": 1,
"content-available": 1,
"badge": 1,
"sound": "default",
"alert": {"loc-key": "SINGLE_UNREAD", "loc-args": []}
}
}
Expand Down Expand Up @@ -557,4 +559,10 @@ class BackgroundPush {
return PushNotificationExtensions().error();
}
}

void clearAllNotifications() {
if (Platform.isIOS) {
apnChannel.invokeMethod('clearAll');
}
}
}
1 change: 1 addition & 0 deletions lib/widgets/matrix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
client.backgroundSync = foreground;
client.syncPresence = foreground ? null : PresenceType.unavailable;
client.requestHistoryOnLimitedTimeline = !foreground;
backgroundPush?.clearAllNotifications();
}

void initSettings() {
Expand Down

0 comments on commit 0d08e40

Please sign in to comment.