//implementing UNUserNotificationCenterDelegatefunc userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) { let userInfo = notification.request.content.userInfo if let notification = Guardian.notification(from: userInfo) { // Implement this function to display the prompt and handle user's consent/rejection. handleGuardianNotification(notification: notification) }}
let device: AuthenticationDevice = // the object you obtained during the initial Guardian SDK enrollment process and stored locallyif let consentId = notification.transactionLinkingId { Guardian .consent(forDomain: {yourTenantDomain}, device: device) .fetch(consentId: consentId, notificationToken: notification.transactionToken) .start{result in switch result { case .success(let payload): // present consent details to the user case .failure(let cause): // something went wrong } }}
Guardian .authentication(forDomain: "{yourTenantDomain}", device: device) .allow(notification: notification) // or reject(notification: notification, withReason: "hacked") .start { result in switch result { case .success: // the auth request was successfully rejected case .failure(let cause): // something failed, check cause to see what went wrong } }
Guardian .authentication(forDomain: "{yourTenantDomain}", device: device) .reject(notification: notification) // or reject(notification: notification, withReason: "hacked") .start { result in switch result { case .success: // the auth request was successfully rejected case .failure(let cause): // something failed, check cause to see what went wrong } }