Quick start: iOS
Define the spec sources and add Huma dependencies and
post_install
in your Podfile:source 'https://github.com/CocoaPods/Specs.git'
source 'git@github.com:huma-engineering/huma-ios-specs.git'
pod 'HumaAppKit'
pod 'HumaHeaderWidget'
pod 'HumaVitalWidget'
pod 'HumaRealmPlugin' # in a short future, we will remove the need to add this pod
# in a short future, we will remove the need to add post_install
# currently, it's needed due to a 3rd-party dependency (FlagPhoneNumber)
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0' # or your minimum deployment target
end
end
end
endDownload the HumaEnvironment.plist file from the Huma workspace and add it to your project's app folder.
Log in to the Huma Workspace.
Download the HumaEnvironment.plist file.
Add it to your project directory.
Import the Huma SDK in AppDelegate.swift:
import UIKit
import HumaFoundation
import HumaAppKitImplement
AnyHumaAuthProvider
protocol:extension APIClient: AnyHumaAuthProvider {
static var initialAuthData: AuthData? {
guard let response = shared.humaTokenResponse else { return nil }
return AuthData(
userID: response.uid,
refreshToken: response.refreshToken,
refreshTokenExpiresIn: response.refreshTokenExpiresIn,
authToken: response.authToken,
authTokenExpiresIn: response.authTokenExpiresIn
)
}
}Initialize the SDK in in the
application(_:didFinishLaunchingWithOptions:)
method:HumaApp.initialize()
Present the screen from SDK in your view controller code:
self.token = HumaApp.presentWidgetScreen(withID: "ScreenID", from: self)
Remember to end user session on log out:
HumaApp.endUserSession()
Make sure that NSCameraUsageDescription and NSMotionUsageDescription keys are present in the Info.plist