iOS SDK Quick Start Start by Using Hyphen iOS SDK
Create an App in the Dashboard
You need to create an app in the Hyphen Dashboard before using Hyphen SDK. After creating an app, an app secret will be issued. The app secret is required to initialize the SDK.
Install the SDK using SPM
We recommend Swift Package Manager to install our SDK.
Swift Using Xcode
Edit Package.swift
of your project to add Hyphen SDK.
Copy import PackageDescription
let package = Package(
name: "my-project",
dependencies: [
.package(url: "https://github.com/hyphen-at/hyphen-ios-sdk.git"),
...
],
targets: [...]
)
In Xcode, Open .xcodeproj
file of your project.
Go to Package Dependencies .
Click + button below to add a dependency.
Enter https://github.com/hyphen-at/hyphen-ios-sdk.git
URL.
Configuring the SDK
On AppDelegate.swift
of your application, insert the following initialization code.
Swift Objective-C
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)
}
}
Sorry, the example is not provided yet.