调整推送

This commit is contained in:
Fin 2020-05-26 10:17:46 +08:00
parent 2db35c6048
commit a60ab895d7

View File

@ -13,7 +13,7 @@ import RealmSwift
import IceCream
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate{
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate{
var window: UIWindow?
var syncEngine: SyncEngine?
@ -34,6 +34,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate{
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
dispatch_sync_safely_main_queue {
if settings.authorizationStatus == .authorized {
UNUserNotificationCenter.current().delegate = self
Client.shared.registerForRemoteNotifications()
}
}
@ -77,7 +78,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate{
//
Client.shared.bindDeviceToken()
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
notificatonHandler(userInfo: notification.request.content.userInfo)
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
notificatonHandler(userInfo: response.notification.request.content.userInfo)
}
private func notificatonHandler(userInfo:[AnyHashable:Any]){
let navigationController = ((self.window?.rootViewController as? BarkSnackbarController)?
.rootViewController as? BarkNavigationController)
@ -150,7 +157,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate{
else{
presentController()
}
}
func applicationWillResignActive(_ application: UIApplication) {