fix homeVC not refreshing because of PN
This commit is contained in:
parent
04c6610e10
commit
4fe78bdda4
|
@ -16,6 +16,14 @@ final class NotificationServiceExtension : UNNotificationServiceExtension {
|
|||
self.contentHandler = contentHandler
|
||||
notificationContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
||||
|
||||
var isMainAppActive = false
|
||||
if let sharedUserDefaults = UserDefaults(suiteName: "group.com.loki-project.loki-messenger") {
|
||||
isMainAppActive = sharedUserDefaults.bool(forKey: "isMainAppActive")
|
||||
}
|
||||
print("[Ryan debug] isMainAppActive \(isMainAppActive)")
|
||||
// If the main app is running, skip the whole process
|
||||
guard !isMainAppActive else { return self.completeWithFailure(content: notificationContent!) }
|
||||
|
||||
// The code using DispatchQueue.main.async { self.setUpIfNecessary() { Modify the notification content } } will somehow cause a freeze when a second PN comes
|
||||
|
||||
DispatchQueue.main.sync { self.setUpIfNecessary() {} }
|
||||
|
|
|
@ -307,6 +307,10 @@ static NSTimeInterval launchStartedAt;
|
|||
return;
|
||||
}
|
||||
|
||||
NSUserDefaults *sharedUserDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.loki-project.loki-messenger"];
|
||||
[sharedUserDefaults setBool:true forKey:@"isMainAppActive"];
|
||||
[sharedUserDefaults synchronize];
|
||||
|
||||
[self ensureRootViewController];
|
||||
|
||||
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
|
||||
|
@ -334,6 +338,10 @@ static NSTimeInterval launchStartedAt;
|
|||
|
||||
[self clearAllNotificationsAndRestoreBadgeCount];
|
||||
|
||||
NSUserDefaults *sharedUserDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.loki-project.loki-messenger"];
|
||||
[sharedUserDefaults setBool:false forKey:@"isMainAppActive"];
|
||||
[sharedUserDefaults synchronize];
|
||||
|
||||
[DDLog flushLog];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue