Handling 2FA Push
Use Hyphen API to handle 2FA request push
Common Data Format
Key
Description
Example
struct TwoFactorAuthStatusPayload: Codable { ...}
func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) {
guard let msgType = userInfo["hyphen:type"] as? String,
let msgDataString = userInfo["hyphen:data"] as? String,
let msgData = msgDataString.data(using: .utf8) else {
// The payload was not a string or the string could not be converted to Data
completionHandler(.failed)
return
}
do {
let decoder = JSONDecoder()
switch msgType {
case "2fa-status-change":
let myData = try decoder.decode(TwoFactorAuthStatusPayload.self, from: msgData)
completionHandler(.myData)
}
} catch {
print("Decoding error: \(error)")
completionHandler(.failed)
}
}
List of Push Message Data
2FA Request (On Destination Device)
Data Format
Key
Description
Example
Example
2FA Status Change (On Source Device)
Data Format
Key
Description
Example
Example
Last updated
Was this helpful?