LOCATION SDK INTEGRATION GUIDE


In this detailed guide, we take you through the steps required to integrate the library with your Android and iOS app.

GETTING THE INTEGRATION KEY
 
STEP 1 - After a legal contract has been signed between the Publisher and Quadrant, an invitation will be sent to Publisher’s email redirecting to register to the platform.
1
 
STEP 2 - Register on the Quadrant Publisher Platform
 
2-Jul-01-2021-06-22-46-69-AM
 
STEP 3 - Once you're logged in, click PUBLISHER DASHBOARD from the menu on the left. This will display your publisher dashboard.
 
3-Jul-01-2021-06-25-30-83-AM
 
STEP 4 - Add your App, and choose 'Location' as SDK type, select your desired OS Type and submit.
 
4-4
 
STEP 5 - Once submitted, your app will be enlisted, but the Integration key will not be displayed yet. At this point, you require an admin's approval. The admin will be automatically notified and can take the needful action.
 
5
 
STEP 6 - Once approved, your integration key will be displayed on the dashboard. You need to distribute this integration key to your app developers.
 
6
 

INTEGRATING THE SDK - ANDROID

STEP 1 - In Android Studio, open build.gradle of the app (the project level), and add codes as highlighted in yellow:
7
STEP 2 - Open build.gradle of the app (the app-specific level), and add this under the 'dependencies' code section (highlighted in yellow):
 
implementation 'io.quadrant.sdk.locationdata:data-acquisition-sdk:<latest version>'
 

Latest version: 1.0.2

Screenshot 2021-06-25 at 14.36.04
STEP 3 - Sync the gradle files, now let’s try calling the setup method for initiating the monetization SDK, fill in INTEGRATION_KEY with the that you fetched from the dashboard.
 
and that's it!
 
If you try accessing a method from the library in your code, it should work.
 
Client.getInstance().setup(MainActivity.this, true, false, INTEGRATION_KEY, new Client.ResultCallback() {
@Override
public void onSuccess(String result) {
//start location data collection
}

@Override
public void onError(String result) {
//add error condition/ alert
}
});

Example:

9

to stop tracking, and reenable tracking, there is a toggle functionality:

1- Client.getInstance().toggleStartTrackingLocation(false);

set the param to false to stop collecting the location tracking, set true to reenable location tracking

Congratulations! You have successfully integrated the library into your android project!

TRACKING LOCATION - ANDROID

STEP 1 - The library requires three permissions to run properly. Declare them in your app manifest.xml file.

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>


STEP 2 -
And to start collecting, call this method

Client.getInstance().startTrackingLocation();

 

Make sure to call the above method inside onSuccess() callback method  Client.getInstance().setup() that we declared before. As shown below:

10

Congratulations! You have now configured everything required for location tracking!

INTEGRATING THE SDK - iOS

STEP 1 - Installation using Cocoapods

Add this line in your Podfile:
pod "QDPublisher", :git => 'https://github.com/datastreamx-plc/ios-data-acquisition-sdk.git'

and then install by type pod install in your command line

 

STEP 2 - Setup Integration Key and Start Tracking

Register your integration key after app launch, after that you can setup your event and start tracking location, usually your AppDelegate.swift

import QDPublisher

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

let publisher = QDPublisher.service
let integrationKey: String = "your integration key here"

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
/// setup integration key
publisher.setup(integrationKey)

///setup event. You need implement method from `QDPublisherDelegate`
publisher.delegate = self

///start tracking location. After you call this method, our SDK will automatically tracking event and do the logic for you
publisher.startTrackingLocation()
}}

Implement QDPublisherDelegate - iOS

After setting publisher.delegate = self you need to implement QDPublisherDelegate

extension AppDelegate: QDPublisherDelegate {

/// this controller used to show alert.
func qdPublisherControllreParent() -> UIViewController? {
window?.rootViewController
}

/// you can handle error in this method.
func qdPublisherOnError(error: Error) {
print(error.localizedDescription)
}

}

Enable Background Update

Click your Project

  • Click Capability

  • Choose Background Modes

  • Enable Location updates

    See images below:

  • Screen Shot 2021-07-02 at 15.18.51
 
Screen Shot 2021-07-02 at 15.19.22
    • TRACKING LOCATION - iOS

      For location tracking, you can use this code QDPublisher.service.track(choosedLocation) in your location service, it usually looks like this: 

    • func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
      guard let choosedLocation: CLLocation = locations.first else { return }
      QDPublisher.service.track(choosedLocation)
      }

       


Ready to add an ethical, hassle-free revenue stream to your business?
Speak to our data consultant to start using Quadrant Location SDK