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.

    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()
  • 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.