UsherSDK
@objc
public final class UsherSDK : NSObject
The primary entry point for all apps that embed UsherSDK. Every app that
wants to use the UsherSDK needs to initialize it with an UsherSDKConfiguration
object.
This class provides APIs for registering UI workflow handlers, passcode management,
discard and resetting sdk state etc.
-
The UsherSDK needs to be initialized with a configuration before any of its APIs are called. The initialization workflow configures shared containers, keychain groups, TLS behavior etc. Attempting to use the UsherSDK API without initialization will result in errors or unexpected behaviors.
See also
UsherSDKConfiguration
Declaration
Swift
@objc(initializeWith:completion:) public class func initialize(with config: UsherSDKConfiguration = UsherSDKConfiguration(), completion: () -> Void)
Parameters
with
An value of type
UsherSDKConfiguration
completion
A completion block called post initialization. For all public API use cases this is called synchronously and hence can be nil or the callback be ignored. Only for some MicroStrategy internal use cases of UsherSDK this will be called asynchronously and the caller is expected to wait before doing any further interactions with the UsherSDK.
-
Returns true if user has set a passcode for badges that require passcode authentication
Declaration
Swift
public class func isPasscodeSet() -> Bool
-
Verifies if the provided passcode matches the passcode previously set by the user.
Declaration
Swift
public class func verifyPasscode(_ passcode: String) -> (result: Bool, attemptsRemaining: Int)
Parameters
passcode
Passcode
Return Value
A tuple with a bool indicating whether the passcode matches and count of the remaining wrong attempts the user can make. Once the attemptsRemaining number gets to 0, all user data managed by the SDK side will be deleted and a notification with name
UsherSDKNotification
.usherSDKDidDeleteUserData
will be posted. -
Set a new passcode. If passcode was set already, the old password needs to be provided.
Declaration
Swift
@discardableResult public class func setPasscode(new: String, old: String?) -> Bool
Parameters
new
The new passcode
old
The previous passcode if it exists.
Return Value
true
if passcode was changed successfully.
-
Deletes local user data for all the configured servers. Once done the
UsherSDKDidDeleteUserData
notification will be posted.Declaration
Swift
public class func deleteUserData()
-
Deletes local user data for the specified server only. This function executes blocks synchronously and returns when done.
Declaration
Swift
public class func deleteUserData(forServer server: Server?)
Parameters
server
unmanaged (realm detached) instance of the server object.
-
Discards all user data and server configurations and resets the SDK. Also discards all UsherSDK managed data from iOS Keychain.
Declaration
Swift
public class func reset()
-
Register a class conforming to
LoginUIProtocol
. UsherSDK uses this class for prompting the user to provide login credentials for various workflows.Declaration
Swift
public static func registerLoginUIClass(_ uiClass: LoginUIProtocol.Type)
Parameters
uiClass
A class conforming to
LoginUIProtocol
-
Register a class conforming to
ServerSwitchUIProtocol
. UsherSDK uses this class for prompting the user to confirm when server switch is needed.Declaration
Swift
public class func registerServerSwitchUIClass(_ uiClass: ServerSwitchUIProtocol.Type)
Parameters
uiClass
A class conforming to
ServerSwitchUIProtocol
-
Register a class conforming to
BadgePickerUIProtocol
. UsherSDK uses this class for prompting the user to select a badge when there are more than one badges on the device, that can be used to perform some actions.Declaration
Swift
public class func registerBadgePickerUIClass(_ uiClass: BadgePickerUIProtocol.Type)
Parameters
uiClass
A class conforming to
BadgePickerUIProtocol
-
Register a class conforming to
SSOConfirmationUIProtocol
. UsherSDK uses this class for prompting the user to provide confirmation during SSO login workflow.Declaration
Swift
public class func registerSSOConfirmationUIClass(_ uiClass: SSOConfirmationUIProtocol.Type)
Parameters
uiClass
A class conforming to
SSOConfirmationUIProtocol
-
Register a class conforming to
EmailRecoveryUIProtocol
. UsherSDK uses this class for prompting the user to provide email address to receive the badge recovery code.Declaration
Swift
public class func registerEmailRecoveryUIClass(_ uiClass: EmailRecoveryUIProtocol.Type)
Parameters
uiClass
A class conforming to
EmailRecoveryUIProtocol
-
Register a class conforming to
UserAgreementUIProtocol
. UsherSDK uses this class for prompting the user to read and agree to the terms of uses and privacy policies.Declaration
Swift
public class func registerUserAgreementUIClass(_ uiClass: UserAgreementUIProtocol.Type)
Parameters
uiClass
A class conforming to
UserAgreementUIProtocol
-
Register a class conforming to
LocationConsentUIProtocol
. UsherSDK uses this class for prompting the user to authorize location access and/or inform user about and errors arising from lack of location authorization to the app.Declaration
Swift
public class func registerLocationConsentUIClass(_ uiClass: LocationConsentUIProtocol.Type)
Parameters
uiClass
A class conforming to
LocationConsentUIProtocol
-
Register a class conforming to
BluetoothConsentUIProtocol
. UsherSDK uses this class for prompting the user to authorize bluetooth access and/or inform user about and errors arising from lack of authorization to access bluetooth.Declaration
Swift
public class func registerBluetoothConsentUIClass(_ uiClass: BluetoothConsentUIProtocol.Type)
Parameters
uiClass
A class conforming to
BluetoothConsentUIProtocol
-
Register a class conforming to
TimeRestrictionUIProtocol
. UsherSDK uses this class for informing the user about restrictions of using the badge for a certain time.See also
Declaration
Swift
public static func registerTimeRestrictionUIClass(_ uiClass: TimeRestrictionUIProtocol.Type)
Parameters
uiClass
A class conforming to
TimeRestrictionUIProtocol
-
Register a class conforming to
GeoFenceUIProtocol
. UsherSDK uses this class for informing the user about restrictions of using the badge in the current location.See also
Declaration
Swift
public class func registerGeoFenceUIClass(_ uiClass: GeoFenceUIProtocol.Type)
Parameters
uiClass
A class conforming to
GeoFenceUIProtocol
-
Register a class conforming to
PhotoUploadUIProtocol
. UsherSDK uses this class for presenting a UI for capturing or selecting a picture.Declaration
Swift
public class func registerPhotoUploadUIClass(_ uiClass: PhotoUploadUIProtocol.Type)
Parameters
uiClass
A class conforming to
PhotoUploadUIProtocol
-
Register a class conforming to
PasscodeUIProtocol
. UsherSDK uses this class for prompting the user to enter a passcode.Declaration
Swift
public class func registerPasscodeUIClass(_ uiClass: PasscodeUIProtocol.Type)
Parameters
uiClass
A class conforming to
PasscodeUIProtocol
-
Register a class conforming to
DeviceProvisioningUIProtocol
. UsherSDK uses this class for prompting the user to enter enrollment phone number, approve sending provisioning code to device and entering provising code for approval.Declaration
Swift
public class func registerDeviceProvisioningUIClass(_ uiClass: DeviceProvisioningUIProtocol.Type)
Parameters
uiClass
A class conforming to
DeviceProvisioningUIProtocol
-
Register a class conforming to
RevokedUIProtocol
. UsherSDK uses this class for prompting the user to delete suspended badge.Declaration
Swift
public class func registerRevokedUIClass(_ uiClass: RevokedUIProtocol.Type)
Parameters
uiClass
A class conforming to
RevokedUIProtocol
-
Checks if the server supports the current version of your app. This method is long running since version support info is requested from the server. Use the completion block to get the result.
Declaration
Swift
public class func checkServerSupports(appVersion: String, completion: @escaping (VersionSupport, UsherErrorProtocol?) -> ())
Parameters
appVersion
Current version of your app
completion
Completion block that will be called with the ‘VersionSupport` result enum and if there was any error communicating with the server.