1. Home
  2. Integrations
  3. iOS PhoneGap Integration Guide

iOS PhoneGap Integration Guide

Welcome to the mTraction iOS PhoneGap SDK Integration Section. Our SDK provides developers the flexibility to choose and integrate one or more components based on their requirements.

Install the SDK

Download the latest iOS Phonegap SDK

Note: Please refer to the iOS SDK Change log for details about the changes/upgrades on the latest SDK version from previous versions.

The mTracktion SDK should contain the following files:

  1. mTraction.framework: This is the SDK library that has to be integrated in the application.
  2. mTracktionResources.bundle: This is the SDK library that has to be integrated in the application.
  3. JS/mTractionData.js : This is the SDK library that has to be integrated in the application.
  4. JS/mtractiontracker.js :This is the javascript file that has to be integrated in the application. .
  5. Plugin/ MTractionSDKTracker.h & MTractionSDKTracker.m: This is the iOS Class file that has to be integrated in the application.
  6. Plugin/ AppDelegate+Notification.h & AppDelegate+Notification.mThis is the iOS Class file that has to be integrated in the application. .

The step-by-step integration process has been described in detail in the coming sections.

  1. Basic Integration Settings
  2. PhoneGap Plugin Configuration
  3. Installs Tracing
  4. App Session Tracking (Optional)
  5. In App Events Integration (Optional)
  6. Application Push Notifications(Optional)

1. Basic Integration Settings


  1. Go to your Project’s Build Phases. Follow the screenshot.
  1. Click on the “+” under “Link Binary With Libraries” to add a new library. Then click on the “Add Other” button. Follow the Screenshot
  2. Click on Add “Other Tab” and browse mTraction.framework and include in the project.
  3. Add the supporting native frameworks in the above-described manner. These frameworks can be found in the native frameworks list already. (Developer need not click on Add Other button.)
    • AdSupport.framework
    • CoreTelephony.framework
    • CoreData.framework
    • UIKit.framework
    • Foundation.framework
  4. To add the mTractionResources.bundle file, simply drag mTractionResources.bundle file into your Xcode, Classes folder. Follow the screenshot.
  5. Also To add an exception to their Info.plist to allow affle http connection for iOS 9.0 and above:
  6. To add the mtractiontracker.js and mTractionData.js file, In the xcode project. Go Staging/www/js folder And simply copy mtractiontracker.js and mTractionData.js file into your Xcode. Follow the screenshot.
  7. Also To add the MTractionSDKTracker.h and MTractionSDKTracker.m file, In the xcode project. Go to Plugins folder simply drag these class file MTractionSDKTracker.h and MTractionSDKTracker.m. Follow the screenshot.
  8. Also To add the AppDelegate+Notification.h and AppDelegate+Notification.m file, In the xcode project. Go to Plugins folder simply drag these class file AppDelegate+Notification.h and AppDelegate+Notification.m. Follow the screenshot

2. PhoneGap Plugin Configuration


  1. In the xcode project, Go Staging folder and open config.xml. Add MTractionSDKTracker  feature in config.xml. Follow the screenshot :
    <feature name="MTractionSDKTracker">
        <param name="ios-package" value="MTractionSDKTracker" />
        <param name="onload" value="true" />
        </feature>

     

3. Installs Tracking

Follow the below steps to track download conversions:

  1. Open your project info.plist available under the Supporting Files section in the Project File Navigator on Xcode.Example: If your project name is mTractiontrackertest, then the plist file name shall be, mTractiontrackertest-Info.plist.
  2. Add a new key in the Information Property List section of the selected project info.plist.

    Key = appToken
    Value Type = String
    Value = <App_Token>

     

    Note: The App_Token is provided to you as a part of the Application Registration process on the mTraction Platform. 

  1. DEBUG Setting (Optional): Open your project info.plist available under the Supporting Files section in the Project File Navigator on Xcode.ExampleIf your project name is mTractionTracker, then the plist file name shall be, mTractionTracker-Info.plist.
    Key = mt_DebugMode
    Value Type = Boolean
    Value = YES (Debug On) or NO (Debug Off)

    Note:Ensure that the Debug Mode is set to “NO” before going live.

  1. Include the mTractionData.js and mtractiontracker.js to your index.html file.
    <script type="text/javascript" src="js/mTractionData.js"></script>
      <script type="text/javascript" src="js/mtractiontracker.js"></script>
  1. Call this method in your index.html. This method implements the functionality of “Tracking the Download Conversion”.
    mTractionDownloadTracker: function()

Sample Code

< script type=”text/javascript” >
document.addEventListener(“deviceready”, onDeviceReady, true);
function onDeviceReady() {
mtractiontracker.mTractionDownloadTracker();
}
< /script>

4. App Session Tracking (Optional)

Note: App Session implementation is optional for your Application. However, for Active Sessions and Session duration related data – this needs to be configured in your Application. Also note that this can generate a lot of traffic and hence cost if the request is large.

To track App Session call the below callbacks in predefined methods in AppDelegate file.

-(void)applicationWillResignActive:(UIApplication *)application
{  
 [[MTraction mTractionManager]applicationWillResignActive];
}

-(void)applicationDidBecomeActive:(UIApplication *)application
{
 [[MTraction mTractionManager]applicationDidBecomeActive];
}

5. In App Events Integration (Optional)

 

  • At this stage, you might be interested in implementing certain In App events that needs to be tracked in order to measure your Application’s User Engagement after being installed. We have provided a list of generic events that you may need to implement depending on its necessity to your Application. Please follow the documentation (with examples) to implement them on your Application: Generic In App Events Setup
  • Additionally, we have also provided sets of predefined In App events along with their respective keys setup (with example usage) based on the Industry or Vertical your Application is associated with. Please refer to the link to the various Vertical based Events integration guides.
  • Additionally, you can implement custom events to track specific behavior on your application. Please follow the documentation (with example): Custom Events Setup Guide

6. Application Push Notifications(Optional)

Follow the below steps to track download conversions:

  1. Open your project info.plist available under the Supporting Files section in the Project File Navigator on Xcode.Example: If your project name is mTractiontrackertest, then the plist file name shall be, mTractiontrackertest-Info.plist.
  2. Add a new key in the Information Property List section of the selected project info.plist info.plist.

    Key = mt_PushNotification
    Value Type = Boolean
    Value = YES

     

  3. Enable Push Notifications from Capabilities in your Xcode project.Follow the screenshot.
  4. Enable Remote Notifications in Background Modes from Capabilities in your Xcode project. Follow the screenshot.
  5. Configure Push Notification- Call this method in your index.html. This method register the functionality of “Push Notification”.
    registerDevice: function()

    Sample Code

    < script type=”text/javascript” >
    document.addEventListener(“deviceready”, onDeviceReady, true);
    function onDeviceReady() {
                mtractiontracker.registerDevice();
    < /script>
  6. Setting up the Push Notification Handlers
    
    

    Application State : In-Active/Background 

    When a push notification is received while the application is not in the foreground, it is displayed in the iOS Notification Center.  When We click on push massage open app and handle by pushNotificationCallBack method.

    Call this method in your index.html.

    onPushNotificationBackgroundCallBack

    Sample Code

    < script type=”text/javascript” >
    document.addEventListener(“deviceready”, onDeviceReady, true);
    function onDeviceReady() {
                mtractiontracker.onPushNotificationBackgroundCallBack();
    < /script>

    Application State : Active/Foreground 

    If the notification is received while the app is active, it is up to the app to handle it. To do so, we can implement the pushNotificationCallBack method in the mtractiontracker.js file.

    Also developer can set custom/own message box in this method.

    onPushNotificationForegroundCallBack: function()

    Sample Code

    < script type=”text/javascript” >
    document.addEventListener(“deviceready”, onDeviceReady, true);
    function onDeviceReady() {
                mtractiontracker.onPushNotificationForegroundCallBack();
    < /script>
    
    

     

Articles

Was this article helpful to you? Yes No

How can we help?