Tonos iOS SDK
Version: 1.1.0
This service allows you to add Tonos to your iOS application. This section of the documentation provides detailed steps on how to succesfully complete this task.
Requirements
Item | Notes |
---|---|
Xcode 9.0+ | Download and install Xcode. |
iOS 10.0+ | The iOS operating system needs to be newer than 10.0. |
Swift 4.0+ | Download and install Swift. |
Tonos license | Request an account from your company admin. |
Adding the Tonos SDK
The preferred method of installation is by using CocoaPods. You need to add the following code snippet to your Podfile:
pod 'TonosSDK', :source => 'https://gjirafadev@dev.azure.com/gjirafadev/GjirafaSpecs/_git/GjirafaSpecs'
Then, run the following command:
pod install
To ensure that you have the latest version (1.1.0) of the SDK, run this command:
pod update 'TonosSDK'
Configuring the Tonos SDK
- Call the
Tonos.setup()
method on your AppDelegate
Parameter | Description |
---|---|
appId | Provided from Tonos when setting up your application |
- Swift
- Objective-C
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Tonos.setup(appId: "Your AppId")
return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[Tonos setupWithAppId:@"cbdc986"];
return YES;
}
Replace the appId
parameter with your applicationId
Displaying the offer
In order to display offers in your application from Tonos, you must invoke the Tonos.fetchOffer()
function.
Param | Type | Description |
---|---|---|
contentId | String | Used to display offers based on it. One contentId represent one page. |
container | UIView (Optional) | Used to display offer if offer we're displaying is inline offer. |
completionHandler | OfferSizeCompletionHandler (Optional) | Used to invoke event back to fetchOffer() method by letting </> know changes on offer size. |
- Swift
- Objective-C
Tonos.fetchOffer(contentId: "Your contentId", container: YourContainerView) { size in
//adjust size of your container view with size of offer
}
[Tonos fetchOfferWithContentId:@"a3a5c53b" container:nil completionHandler:^(CGSize size) {
//adjust size of your container view with size of offer
}];
Replace contentId
& containerView
with your own values.
Additionally you can invoke the Tonos.stopOffer()
in order to dismiss any modal showing offers & cancel the last fetching offer. This is usually used when you start fetchOffer()
and the user navigates back to the previous page, in which case we need to stop fetching the last offer & dismiss if it has been shown already.
- Swift
- Objective-C
Tonos.stopOffer()
[Tonos stopOffer];
Analytics
When users interact with offers, their actions trigger different events. Below you will find some methods of listening to these events listed along with a desription for each of them.
Implementing the delegate
The code snippets below provide information on how to execute this process using either Kotlin.
- Swift
- Objective-C
Tonos.on { event, args in
if event == .accessible {
// Tonos is ready for use
}
}
[Tonos onEvent:^(enum TonosEvent event, id _Nonnull) {
if (event == TonosEventAccessible) {
// Tonos is ready for use
}];
Tonos events
Param | Type | Description |
---|---|---|
state | TonosState | Notifies user about different states (Check TonosState model table below). |
value | Any | If there are any data available which can be passed to our user, they'll be done using a value parameter. |
TonosState ACCESSIBLE | |
---|---|
Event | ACCESSIBLE |
Description | Fired wen Tonos is ready for use. |
Return Type Value | TonosState APP_INITIALIZE |
Event | APP_INITIALIZE |
Description | Fired when the application is initialized. |
Return Type Value | TonosState PAGE_INITIALIZE |
Event | PAGE_INITIALIZE |
Description | Fired when the page is initialized. |
Return Type Value | TonosState LOGIN_SHOW |
Event | LOGIN_SHOW |
Description | Fired when the login form is shown. |
Return Type Value | TonosState LOGIN_SUCCESS |
Event | LOGIN_SUCCESS |
Description | Fired when the login process is successful. |
Return Type Value | TonosState OFFER_SHOWN |
Event | OFFER_SHOWN |
Description | Fired when the offer is shown. |
Return Type Value | TonosState OFFER_CLOSED |
Event | OFFER_CLOSED |
Description | Fired when the offer is closed. |
Return Type Value | TonosState CHECKOUT_SHOW |
Event | CHECKOUT_SHOW |
Description | Fired when the checkout for is shown. |
Return Type Value | TonosState CHECKOUT_ABANDONED |
Event | CHECKOUT_ABANDONED |
Description | Fired when the checkout process is abandoned. |
Return Type Value | TonosState CHECKOUT_SUCCESS |
Event | CHECKOUT_SUCCESS |
Description | Fired when the checkout process is successful. |
Return Type Value | TonosState CHECKOUT_FAILED |
Event | CHECKOUT_FAILED |
Description | Fired when the checkout process fails. |
Return Type Value | TonosState PLAN_SELECTED |
Event | PLAN_SELECTED |
Description | Fired when a subscription plan is selected. |
Return Type Value | TonosState PAYMENT_SHOW |
Event | PAYMENT_SHOW |
Description | Fired when a payment is shown. |
Return Type Value |