SuprSendSdk is deprecated. Please migrate to SuprSend SDK

This documentation is for new version of iOS sdk. If you are using older version of sdk SuprSendSdk please refer documentation

Installation

There are two ways you can install SuprSend SDK into your app:

Integration

1

Create Client

Import SDK inside AppDelegate.swift and then initialize the SuprSend class inside application(_:didFinishLaunchingWithOptions:) method.

import SuprSend

SuprSend.shared.configure(publicKey: "YOUR_PUBLIC_API_KEY")
ParamsDescription
publicApiKey*This is public Key used to authenticate API calls to SuprSend. Get it in SuprSend dashboard ApiKeys -> Public Keys section
2

Authenticate User

Authenticate user so that all the actions performed after authenticating will be w.r.t that user. This is mandatory step and need to be called before using any other method. This is usually performed after successful login and on reload of page to re-authenticate user.

await SuprSend.shared.identify(distinctID: "YOUR_USER_ID", userToken: userTokenData, options: AuthenticateOptions(refreshUserToken: {oldUserToken,tokenPayload in return refreshedUserToken()}));
PropertiesDescription
distinctId*Unique identifier to identify a user across platform.
userTokenMandatory when enhanced security mode is on. This is ES256 JWT token generated in your server-side. Refer docs to create userToken.
refreshUserTokenThis function is called by SDK internally to get new userToken before existing token is expired. The returned string is used as the new userToken.

Returns: async -> APIResponse

2.1 Check if user is authenticated

This method will check if user is authenticated i.e. distinctId is attached to SuprSend instance. To check for userToken also pass checkUserToken flag true.

SuprSend.shared.isIdentified(checkUserToken: true)
3

Reset user

This will remove user data from SuprSend instance. This is usually called on logout action.

await SuprSend.shared.reset()

Returns: async -> APIResponse

Response Structure

struct APIResponse {
  /// The status of the response (success or error).
  public let status: ResponseStatus

  /// The HTTP status code associated with the response.
  public let statusCode: StatusCode?

  /// The JSON response body.
  public let body: ResponseBody?

  /// Any error that occurred during the request. {type: string, message: string}
  public let error: ResponseError?

}