Created
October 5, 2020 07:17
-
-
Save asilturk/99e34e63f1df6edc6a4f368cac284936 to your computer and use it in GitHub Desktop.
notificationTapped
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { | |
let userInfo = response.notification.request.content.userInfo | |
// Uygulama calisiyorken (on/arka planda) kullanici bildirime tikladiginda burdan yonlendirilir | |
NotificationCenter.default.post(name: Notification.Name("NotificationTapped"), object: nil, userInfo: userInfo) | |
// user tapped the notification bar when the app is in foreground | |
if(UIApplication.shared.applicationState == .active) { } | |
// user tapped the notification bar when the app is in background | |
if(UIApplication.shared.applicationState == .inactive) { } | |
completionHandler() | |
} | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
// ... | |
// Uygulama calismiyorken (terminated), bildirime tiklandiginda yonlendirmeyi saglar. | |
if let remoteNotification = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String : Any] { | |
DispatchQueue.main.asyncAfter(deadline: .now() + 2) { | |
NotificationCenter.default.post(name: Notification.Name("NotificationTapped"), object: nil, userInfo: remoteNotification) | |
} | |
} | |
return true | |
} | |
// uygulama acik iken notificaiton gosterilmesi | |
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { | |
completionHandler([.alert, .sound]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment