GetSocial

@objcMembers
public class GetSocial : NSObject

Interface for common methods.

  • Return version of GetSocial framework.

    Declaration

    Swift

    public static func sdkVersion() -> String

    Return Value

    Framework version, like 7.0.0

  • Indicate if the device the app is running on added as test device to GetSocial Dashboard.

    Declaration

    Swift

    public static func isTestDevice() -> Bool

    Return Value

    true, if added, otherwise false.

  • Return device identifier.

    Declaration

    Swift

    public static func deviceIdentifier() -> String

    Return Value

    Device identifier. If Limit Ad Tracking is enabled, the returned value contains only 0s.

Initialization

  • Initialize the SDK. Use OnInitializedListener to be notified when SDK is initialized.

    GetSocial App Id will be taken from getsocial.json file.

    Declaration

    Swift

    public static func initSdk()
  • Initialize the SDK. Use OnInitializedListener to be notified when SDK is initialized.

    Declaration

    Swift

    @objc(initSdkWithAppId:)
    public static func initSdk(appId: String)

    Parameters

    appId

    GetSocial App Id, you can find your App Id on GetSocial Dashboard.

  • Initialize the SDK with a specific user. SDK should be uninitialized at that moment.

    Declaration

    Swift

    @objc(initSdkWithIdentity:success:failure:)
    public static func initSdk(identity: Identity, success: @escaping SuccessCallback, failure: @escaping FailureCallback)

    Parameters

    identity

    Identity of the user.

    success

    Called if operation succeeded.

    failure

    Called if operation failed.

  • Set listener to be invoked when SDK initialized.

    It will be executed immediately, if SDK is already initialized.

    Declaration

    Swift

    public static func addOnInitializedListener(_ listener: @escaping OnInitializedListener)

    Parameters

    listener

    Listener to be invoked.

  • Indicate the status of GetSocial framework.

    Declaration

    Swift

    public static func isInitialized() -> Bool

    Return Value

    true, if initialization finished, otherwise false.

GetSocial User

  • Return instance of current GetSocial user.

    Declaration

    Swift

    public static func currentUser() -> CurrentUser?

    Return Value

    User instance, or nil if initialization is not finished or failed.

User Changed Handler

  • Set listener to be invoked when current user changed.

    The action is executed on the main thread, so be careful with operations that you put inside the block.

    Handler will be called in the following cases:

    • SDK initialization finished.
    • switchUser method was called and user was changed.
    • resetUser method was called.

    Declaration

    Swift

    @discardableResult
    public static func addOnCurrentUserChangedListener(_ listener: @escaping OnCurrentUserChangedListener) -> String

    Parameters

    listener

    Listener to be invoked.

    Return Value

    Id to use in removeOnCurrentUserChangedListener.

  • Remove previously added listener.

    Declaration

    Swift

    public static func removeOnCurrentUserChangedListener(_ id: String)

    Parameters

    id

    Listener id to be removed.

Languages

  • Set the language of GetSocial framework.

    If provided value is incorrect, the default language will be used.

    Declaration

    Swift

    @discardableResult
    @objc(setLanguage:)
    public static func setLanguage(_ languageCode: String) -> Bool

    Parameters

    languageCode

    Check possible values in LanguageCodes class.

    Return Value

    true, if operation was successful, otherwise false.

  • Return the current language of GetSocial framework.

    Declaration

    Swift

    public static func language() -> String

    Return Value

    Language code as defined in LanguageCodes.

Actions

  • Handle action using the default GetSocial behaviour.

    Declaration

    Swift

    @objc(handleAction:)
    public static func handle(_ action: Action)
  • Reset current user and creates a new anonymous user.

    Declaration

    Swift

    @objc(resetUserWithSuccess:failure:)
    public static func resetUser(success: @escaping SuccessCallback, failure: @escaping FailureCallback)

    Parameters

    success

    Called if user was reset.

    failure

    Called if operation failed.

  • Reset current user and without creating a new user.

    Declaration

    Swift

    @objc(resetWithSuccess:failure:)
    public static func reset(_ success: @escaping SuccessCallback, failure: @escaping FailureCallback)

    Parameters

    success

    Called if user was reset.

    failure

    Called if operation failed.

  • Switch the current user to another user identified by the provided identity.

    Declaration

    Swift

    @objc(switchUserToIdentity:success:failure:)
    public static func switchUser(to identity: Identity, success: @escaping SuccessCallback, failure: @escaping FailureCallback)

    Parameters

    identity

    Identity that current user should be switched to.

    success

    Called if user was switched.

    failure

    Called if operation failed.