ironSource.atom SDK for iOS
Atom-iOS is the official ironSource.atom SDK for the iOS platform! Follow the steps below to integrate this SDK in your project:
Step 1. Install the SDK
Step 2. Send Events
Before You Start
Make sure to complete the account setup for Atom before you integrate the SDK. You can follow our guidelines to set up your account here.
Make sure to complete the account setup for Atom before you integrate the SDK. You can follow our guidelines to set up your account here.
Step 1. Install the SDK
Instal the Atom iOS SDK through Cocoapods
Add the following dependency to your pod file:
pod 'AtomSDK'
Step 2. Send Events
The Atom SDK for iOS is divided into 2 separate services:
- High Level API Tracker
This tracker follows events based on default parameters and stores them in the device memory. You can also modify the below parameters as you see fit. You can use track() method in order to track the events to an Atom Stream. The tracker accumulates events and flushes them when it meets one or more of the following conditions :Parameter Name Type Attributes Description Default Flush Interval Number Optional Event Sending Interval 10 seconds Bulk Length Number Optional Number of Records in Each Bulk Request 1000 events Maximum Request Limit Number Optional Size of Request in Bytes 64 KB Tracker usage (Swift)
class ViewController: UIViewController { var apiTracker_: IronSourceAtomTracker? override func viewDidLoad() { super.viewDidLoad() // initialize atom-sdk api object self.apiTracker_ = IronSourceAtomTracker() self.apiTracker_!.enableDebug(true) self.apiTracker_!.setAuth("<YOUR_AUTH_KEY>") self.apiTracker_!.setBulkSize(<BULK_COUNT>) self.apiTracker_!.setBulkBytesSize(<MAX_BULK_SIZE_IN_BYTES>) self.apiTracker_!.setEndpoint("https://track.atom-data.io/") } @IBOutlet var textArea_: UITextView! // track event @IBAction func buttonTackPressed(sender: UIButton) { self.apiTracker_!.track("<YOUR_STREAM_NAME>", data: "{\"test\":\"test\"}") } // flush all data in tracker @IBAction func buttonFlushPressed(sender: UIButton) { self.apiTracker_!.flush() }
- Low Level API usage
This API contains 2 methods; once you call one of these methods, you will send the event to Atom:putEvent()
in order to send one eventputEvents()
to send a batch of events
Tracker Usage (Swift)class ViewController: UIViewController { var api_: IronSourceAtom? override func viewDidLoad() { super.viewDidLoad() // initialize atom-sdk api object self.api_ = IronSourceAtom() // print debug info in console self.api_!.enableDebug(true) self.api_!.setAuth("<YOUR_AUTH_KEY>") } @IBOutlet var textArea_: UITextView! func postCallback(response: Response) { print("from class method \(self.test)") let errorStr = (response.error == "") ? "nil" : "\"\(response.error)\"" let dataStr = (response.data == "") ? "nil" : "\"\(response.data)\"" let statusStr = "\(response.status)" let responseStr = "{\n\t\"error\": \(errorStr), " + "\n\t\"data\": \(dataStr), " + "\n\t\"status\": \(statusStr)\n}" dispatch_sync(dispatch_get_main_queue()) { self.textArea_.text = responseStr } } // send single POST request @IBAction func buttonPostPressed(sender: UIButton) { self.api_!.putEvent("<YOUR_STREAM_NAME>", data: "{\"test\":\"test\"}", method: HttpMethod.POST, callback: postCallback) } // senf Bulk request @IBAction func buttonBulkPressed(sender: UIButton) { func callback(response: Response) { let errorStr = (response.error == "") ? "nil" : "\"\(response.error)\"" let dataStr = (response.data == "") ? "nil" : "\"\(response.data)\"" let statusStr = "\(response.status)" let responseStr = "{\n\t\"error\": \(errorStr), " + "\n\t\"data\": \(dataStr), " + "\n\t\"status\": \(statusStr)\n}" dispatch_sync(dispatch_get_main_queue()) { self.textArea_.text = responseStr //Yay! } } // check health of server self.api_!.health(nil) self.api_!.putEvents("<YOUR_STREAM_NAME>", data: ["{\"test\":\"test\"}", "{\"test\":\"test\"}"], callback: callback) }
Please refer to this documentation for more detailed information on every method and its correct usage.
Implementation Example
See our example section that illustrates how to send data to Atom:
For more information on the ironSource.Atom SDK for iOS, visit our dedicated github page.