iOS SDK: Methods
Initialization methods
initialization
Call it:
- after receiving the user’s response to the IDFA/IDFV tracking request;
- on the main thread only.
Mindbox.shared.initialization(configuration: MBConfiguration)notificationsRequestAuthorization
Call this method to pass the notification permission status to the SDK.
Mindbox.shared.notificationsRequestAuthorization(granted: Bool)Dispatch.main.async {
Mindbox.shared.notificationsRequestAuthorization(granted: Bool)
}apnsTokenUpdate
Call this method to pass the APNS token to the SDK.
Use didRegisterForRemoteNotificationsWithDeviceToken in AppDelegate.
Mindbox.shared.apnsTokenUpdate(deviceToken: deviceToken)registerBGTasks
Call this method to register background tasks for iOS 13 and above.
Use the didFinishLaunchingWithOptions method in AppDelegate.
if #available(iOS 13.0, *) {
Mindbox.shared.registerBGTasks()
}
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)Retrieving data from the SDK
getDeviceUUID
The method invokes the provided callback with a DeviceUUID value used by the SDK.
It returns an identifier that can be used to unsubscribe from the callback.
public func getDeviceUUID(_ completion: @escaping (String) -> Void)Mindbox.shared.getDeviceUUID { uuid in
self.deviceUUID = uuid
}sdkVersion
A property that stores the current SDK version
Mindbox.shared.sdkVersionisMindboxPush (since 2.8.3)
The method takes a UNNotification as a parameter.
It returns true or false, depending on whether the push notification was sent by Maestra.
public func isMindboxPush(notification: UNNotification) -> BoolMindbox.shared.isMindboxPush(notification: notification)getMindboxPushData (since 2.8.3)
The method takes a UNNotification as a parameter.
It returns an optional MBPushNotification model if the push notification was sent by Maestra; otherwise, it returns nil.
public func getMindboxPushData(notification: UNNotification) -> MBPushNotification?guard let mindboxPushModel = Mindbox.shared.getMindboxPushData(notification: notification) else {
return
}getAPNSToken
Call this method to request a callback with the APNS token stored in the SDK.
This method returns the ID that can be used to unsubscribe from the callback.
public func getAPNSToken(_ completion: @escaping (String) -> Void)Mindbox.shared.getAPNSToken { token in
DispatchQueue.main.async {
self.apnsTokenFromSDK = token
}
}Sending push statistics
pushClicked
A method for reporting a push notification tap event. It accepts either the full notification object or the unique key strings.
- For a tap on the notification body, pass only the
uniqueKey. - For a button tap, pass both
uniqueKeyandbuttonUniqueKey(for the button the user tapped).
The method accepts any of the following 3 arguments:
- response: <#T##UNNotificationResponse#>
- uniqueKey: <#T##String#>
- uniqueKey: <#T##String#>, buttonUniqueKey: <#T##String?#>
Mindbox.shared.pushClicked( )Mindbox.shared.pushClicked(response: response)Tracking events
Events in Maestra are passed using the API methods configured in your project. These events can be called in two modes:
- asynchronous — Maestra’s API responds with a 200 status once it receives the data. Data is processed in background mode.
- synchronous — Maestra’s API starts processing the call once the data has been received and responds with a relevant processing status.
Learn more about event tracking via the iOS SDK.
executeAsyncOperation
Call this method to run it asynchronously.
Mindbox.shared.executeAsyncOperation(
operationSystemName: "<operation system name>",
operationBody: <operation body>
)executeSyncOperation
Call this method to run it synchronously. Data will be returned through the submitted callbacks.
public func executeSyncOperation<T>(
operationSystemName: "<operation system name>",
operationBody: <operation body>,
completion: @escaping (Result<OperationResponse, MindboxError>) -> Void
) where T: OperationBodyRequestType {}public func executeSyncOperation<T, P>(
operationSystemName: "<operation system name>",
operationBody: <operation body>,
customResponseType: P.Type,
completion: @escaping (Result<P, MindboxError>) -> Void
) where T: OperationBodyRequestType, P: OperationResponseType {}Managing logs
To control the logging level during development, set the desired value for the logger parameter.
Available values:
- debug
- info
- default
- error
- fault
- none
Mindbox.logger.logLevel = .errorMindbox.logger.log()
A dedicated function for logging data using our logger. Use this function to log Maestra-related information.
Mindbox.logger.log(level: LogLevel, message: String)Mindbox.logger.log(level: .debug, message: "My message")Updated 7 months ago

