Copy import FirebaseMessaging
import HyphenAuthenticate
import HyphenCore
import HyphenUI
import UIKit
import UserNotifications
@main
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
// initializes Hyphen SDK.
Hyphen.shared.appSecret = "<INSERT-YOUR-SECRET-HERE>"
Hyphen.shared.network = .flowTestnet // or flowMainNet
HyphenAuthenticateAppDelegate.shared.application(application)
HyphenUI.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
}
/// Updates the push token for Hyphen 2FA.
func application(_: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Hyphen.shared.apnsToken = deviceToken
}
/// Handles the Hyphen 2FA silent push.
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) async -> UIBackgroundFetchResult {
await Hyphen.shared.application(application, didReceiveRemoteNotification: userInfo)
return .newData
}
/// Handles the Hyphen 2FA notification.
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
await Hyphen.shared.userNotificationCenter(center, didReceive: response)
}
/// Handle when the app is opened through the 2FA notification
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
HyphenAuthenticateAppDelegate.shared.application(app, open: url, options: options)
}
}