Skip to main content

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

ItemNotes
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 licenseRequest 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

  1. Call the Tonos.setup() method on your AppDelegate
ParameterDescription
appIdProvided from Tonos when setting up your application

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Tonos.setup(appId: "Your AppId")
return true
}

NOTE

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.

ParamTypeDescription
contentIdStringUsed to display offers based on it. One contentId represent one page.
containerUIView (Optional)Used to display offer if offer we're displaying is inline offer.
completionHandlerOfferSizeCompletionHandler (Optional)Used to invoke event back to fetchOffer() method by letting </> know changes on offer size.

Tonos.fetchOffer(contentId: "Your contentId", container: YourContainerView) { size in
//adjust size of your container view with size of offer
}

NOTE

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.


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.


Tonos.on { event, args in
if event == .accessible {
// Tonos is ready for use
}
}


Tonos events

ParamTypeDescription
stateTonosStateNotifies user about different states (Check TonosState model table below).
valueAnyIf there are any data available which can be passed to our user, they'll be done using a value parameter.
TonosState ACCESSIBLE
EventACCESSIBLE
DescriptionFired wen Tonos is ready for use.
Return Type Value
TonosState APP_INITIALIZE
EventAPP_INITIALIZE
DescriptionFired when the application is initialized.
Return Type Value
TonosState PAGE_INITIALIZE
EventPAGE_INITIALIZE
DescriptionFired when the page is initialized.
Return Type Value
TonosState LOGIN_SHOW
EventLOGIN_SHOW
DescriptionFired when the login form is shown.
Return Type Value
TonosState LOGIN_SUCCESS
EventLOGIN_SUCCESS
DescriptionFired when the login process is successful.
Return Type Value
TonosState OFFER_SHOWN
EventOFFER_SHOWN
DescriptionFired when the offer is shown.
Return Type Value
TonosState OFFER_CLOSED
EventOFFER_CLOSED
DescriptionFired when the offer is closed.
Return Type Value
TonosState CHECKOUT_SHOW
EventCHECKOUT_SHOW
DescriptionFired when the checkout for is shown.
Return Type Value
TonosState CHECKOUT_ABANDONED
EventCHECKOUT_ABANDONED
DescriptionFired when the checkout process is abandoned.
Return Type Value
TonosState CHECKOUT_SUCCESS
EventCHECKOUT_SUCCESS
DescriptionFired when the checkout process is successful.
Return Type Value
TonosState CHECKOUT_FAILED
EventCHECKOUT_FAILED
DescriptionFired when the checkout process fails.
Return Type Value
TonosState PLAN_SELECTED
EventPLAN_SELECTED
DescriptionFired when a subscription plan is selected.
Return Type Value
TonosState PAYMENT_SHOW
EventPAYMENT_SHOW
DescriptionFired when a payment is shown.
Return Type Value