For my statistics dashboard inside the backend i need to call a rest-api via alamofire that informs the backend that the user opened the app through a push notification.
How can I achieve that?
For my statistics dashboard inside the backend i need to call a rest-api via alamofire that informs the backend that the user opened the app through a push notification.
How can I achieve that?
I worked with local notifications so i will give you an example about what i do. I dont know if its the same way for push notifications.
What i do is to set appdelegate to conform to User Notifications delegate
1: Import
import UserNotifications
2: Add protocol
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate
3: Notification Center Instance
var notificationCenter: UNUserNotificationCenter!
4: Initialize and set delegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
notificationCenter = UNUserNotificationCenter.current()
notificationCenter.delegate = self
return true
}
5: NotificationCenter response
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
print("notification pressed")
}