Still Stuck? Talk to us

Report 6 Downloads 45 Views
1/7/14

Article | InMobi Support Portal Careers

LOGIN

Countries

Contact Us

SIGN UP FREE

Support > Integration > Partner Platforms > Appcelerator Partner Platform Integration Guide

Requirements Downloading the Module Installing the Module

Appcelerator Partner Platform Integration Guide Requirements

Configuring the Module

Titanium Studio 3.1.1 GA

Loading the Plugin

You need the Titanium Studio to build cross platform mobile applications. More information about Titanium Studio can be found here.

Accessing the Titanium Window Ob... Creating a Banner Ad Creating an Interstitial Ad

Regarding Support for IOS 7 64 bit : The SDK Release Notes mentions that this release targets, and supports 32-bit iOS apps that run correctly on all Apple iOS devices, including the 64-bit iPhone 5S. A future SDK provides support for all 64-bit iOS apps. We will update the module to 64 bit once the SDK supports 64-bit iOS apps.

BannerAd and InterstitialAd Obje... Network Parameters

Downloading the Module You can download the Titanium Module here.

Still Stuck? Talk to us We are available 5 days a week and here

Installing the Module There are two ways of installing the module.

to help. We will respond as soon as possible, almost always within 24 hours.

Local Installation: With this approach, the module is available only for specific Titanium projects. You need to copy/drag the Titanium InMobi module ZIP file to the Titanium Project root folder.

Ask a Question!

Global Installation: With this approach, the module is available to all the Titanium projects in the system. You will need to copy the Titanium InMobi module ZIP file to the Titanium Modules Folder. For reference, go through the Titanium Guide.

Configuring the Module After installing the module, you need to configure your Titanium Project configuration file. Update your tiapp.xmlfile by adding the following line in the modulesblock.

<modules>  <module>ti.inmobi

OR <modules>  <module version="2.0">ti.inmobi

You should also add the following permissions for Android in the tiapp.xmlfile:  14  <manifest>        <uses‐permission android:name="android.permission.ACCESS_GPS"/>

www.inmobi.com/support/art/23846096/22114287/appcelerator-partner-platform-integration-guide/

1/8

1/7/14

Article | InMobi Support Portal  <uses‐permission android:name="android.permission.ACCESS_GPS"/>  <uses‐permission android:name="android.permission.ACCESS_ASSISTED_GPS"/>  <uses‐permission android:name="android.permission.ACCESS_LOCATION"/>  <uses‐permission android:name="android.permission.READ_PHONE_STATE"/>  <uses‐permission android:name="android.permission.INTERNET"/>  <uses‐permission android:name="android.permission.ACCESS_NETWORK_STATE"/>  <uses‐permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>  <uses‐permission android:name="android.permission.ACCESS_FINE_LOCATION"/>  <uses‐permission android:name="android.permission.CALL_PHONE"/>  <uses‐permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>  

Loading the Plugin In your app.js(controller file), you can load the module by calling the required function. var Inmobi = require('ti.inmobi');

Before requesting InMobi ads, you need to invoke InMobi with the app ID using the initWithParams method.

Usage Inmobi.initWithParams(appId, optionalInMobiParams);

You can use Site ID/App ID specific to your device with the ifcondition. var appId = “android_appId”; // Default Android App ID if (OS_IOS) {   appId = “ios_appId”; }

Example Inmobi.initWithParams("68755e31ebf943c5baa77128523a4de4", { "logLevel": Inmobi.CONSTANTS.LOGLEVEL_NONE, "gender": Inmobi.CONSTANTS.GENDER_MALE, "education": Inmobi.CONSTANTS.EDUCATION_HIGHSCHOOLORLESS, "ethnicity": Inmobi.CONSTANTS.ETHNICITY_ASIAN,  "dob": "29‐11‐1984", "income": "0", "age": "0", "maritalStatus": Inmobi.CONSTANTS.MARITAL_STATUS_SINGLE, "hasChildren": Inmobi.CONSTANTS.TRUE, "sexualOrientation": Inmobi.CONSTANTS.SEXUAL_ORIENTATION_STRAIGHT, "language": "eng", "postalCode": "11111", "areaCode": "435", "interests": "swimming, adventure sports" });

Accessing the Titanium Window Object Titanium has introduced the Alloy framework in the 3.X version. It is based on the model-view-controller architecture. To access the UI component within a controller, you need the ID attribute for the UI component in the views.xmlfile. For example, the Window component in the screenshot has its ID defined as window, and can

be referenced in the controller using $.window.

www.inmobi.com/support/art/23846096/22114287/appcelerator-partner-platform-integration-guide/

2/8

1/7/14

Article | InMobi Support Portal

Inside your controller, you can create a local variable and access the UI component. var window = $.window;

For more information, go here.

Creating a Banner Ad Usage var bannerAd = InMobi.createBannerAd(bannerObjectParams) window.add(bannerAd); // will add banner object to window.

If you have turned off auto-refresh for banner, then you can invoke refresh(). bannerAd.refresh() // will refresh the banner ad.

You can access the window object from Alloy XML markup through its ID attribute. You can refer here for more information. bannerObjectParamsis the JSON object.

#

Key

Mandatory

Values

Value Type

1

appId

This is optional. If you want to pass an appId different from the one used during initialization.

2

backgroundColor

Standard colours or hex value in

String

string.

3

top

YES

Numeric

4

left

YES

Numeric

5

width

YES

Numeric

6

height

YES

Numeric

7

adSize

YES

Inmobi.CONSTANTS.ADSIZE_320X50 Inmobi.CONSTANTS.ADSIZE_300X250 Inmobi.CONSTANTS.ADSIZE_468X60 Inmobi.CONSTANTS.ADSIZE_728X90

www.inmobi.com/support/art/23846096/22114287/appcelerator-partner-platform-integration-guide/

3/8

1/7/14

Article | InMobi Support Portal Inmobi.CONSTANTS.ADSIZE_120X600 8

refreshInterval

Default is 60 seconds

Numeric

9

keywords

Comma-separated string

String

10

additionalParams

Key/value pairs of strings

Object

11

refTagKey

String

12

refTagValue

String

13

disableHardwareAcceleration

Inmobi.CONSTANTS.TRUE /

Boolean

Inmobi.CONSTANTS.FALSE

(Android Specific) Example var bannerAd = Inmobi.createBannerAd({  "backgroundColor":"red",  "top": 0,  "left": 0,  "width":320,  "height":50,  "adSize": Inmobi.CONSTANTS.ADSIZE_320X50,  "refreshInterval": "50",  "keywords": "games, chess, magazines",  "additionalParams": { "myname": "nkapser" } });

You will need to add the bannerAdobject to the window to display the ads.

window.add(bannerAd);

Creating an Interstitial Ad Usage var interstitialAd = InMobi.createInterstitialAd(interstitialObjectParams) CreateInterstitialAd will return Interstitial object.

You need to invoke the load()method to load the interstitial ad. interstitialAd.load();

You need to invoke the show()method to display the ad. interstitialObjectParamsis the JSON object.

#

Key

Values

Value Type

1

keywords

Comma-separated string

String

2

additionalParams

Key/value pairs of strings

Object

3

disableHardwareAcceleration

Inmobi.CONSTANTS.TRUE /

Boolean

(Android Specific)

Inmobi.CONSTANTS.FALSE

var interstitialAd = Inmobi.createInterstitialAd({  // Optional Params  additionalParams: {},  keywords: 'music, jazz, guitar' // provides App View context. });

www.inmobi.com/support/art/23846096/22114287/appcelerator-partner-platform-integration-guide/

4/8

1/7/14

Article | InMobi Support Portal // Android needs to get the current activity. if (OS_ANDROID){   window.add(interstitialAd); } interstitialAd.load(); interstitialAd.show();

BannerAd and InterstitialAd Object Callbacks We have the same callback names for banner ad and interstitial ad. onAdRequestCompleted This callback is fired after receiving the ad response. onAdRequestFailed This callback is fired when an adRequestfails. This response function includes the event object that has the error message. bannerAd.addEventListener('onAdRequestFailed', function(e){     Ti.API.info("Failed to receive Ad! "+e.message); });

onClick This event is fired when user clicks an ad. beforePresentScreen This event is available only for iOS. This event is fired just before ad goes full screen. This callback is called for expandable and interstitial ads. beforeDismissScreen This event is available only for iOS. This event is fired before dismissing the full screen view of the ad. This callback is called for expandable and interstitial ads. onDismissScreen This event is fired after dismissing the full screen view of the ad. This callback is called for expandable and interstitial ads. onLeaveApplication This event will be fired just before the application goes to the background because the user has clicked on an ad that will launch another application (such as the App Store).

Network Parameters The following network parameters are used during initialization of the InMobi module, which is called for the first time before requesting banner or interstitial ads. #

Key

1

logLevel

Values Inmobi.CONSTANTS.LOGLEVEL_NONE Inmobi.CONSTANTS.LOGLEVEL_DEBUG Inmobi.CONSTANTS.LOGLEVEL_VERBOSE

2

gender

Inmobi.CONSTANTS.GENDER_MALE Inmobi.CONSTANTS.GENDER_FEMALE Inmobi.CONSTANTS.UNKNOWN

3

education

Inmobi.CONSTANTS.EDUCATION_HIGHSCHOOLORLESS Inmobi.CONSTANTS.EDUCATION_COLLEGEORGRADUATE Inmobi.CONSTANTS.EDUCATION_POSTGRADUATEORABOVE Inmobi.CONSTANTS.EDUCATION_UNKNOWN

www.inmobi.com/support/art/23846096/22114287/appcelerator-partner-platform-integration-guide/

5/8

1/7/14

Article | InMobi Support Portal 4

ethnicity

Inmobi.CONSTANTS.ETHNICITY_ASIAN Inmobi.CONSTANTS.ETHNICITY_HISPANIC Inmobi.CONSTANTS.ETHNICITY_AFRICAN_AMERICAN Inmobi.CONSTANTS.ETHNICITY_CAUCASIAN Inmobi.CONSTANTS.ETHNICITY_OTHER Inmobi.CONSTANTS.ETHNICITY_UNKNOWN

5

dob

6

income

7

age

8

maritialStatus

Format: dd-mm-yyyy Numeric (should be in USD) Range: 0-100 Inmobi.CONSTANTS.MARITAL_STATUS_SINGLE Inmobi.CONSTANTS.MARITAL_STATUS_DIVORCED Inmobi.CONSTANTS.MARITAL_STATUS_ENGAGED Inmobi.CONSTANTS.MARITAL_STATUS_RELATIONSHIP Inmobi.CONSTANTS.MARITAL_STATUS_UNKNOWN

9

hasChildren

Inmobi.CONSTANTS.TRUE Inmobi.CONSTANTS.FALSE Inmobi.CONSTANTS.UNKNOWN

10

sexualOrientation

Inmobi.CONSTANTS.SEXUAL_ORIENTATION_STRAIGHT Inmobi.CONSTANTS.SEXUAL_ORIENTATION_BISEXUAL Inmobi.CONSTANTS.SEXUAL_ORIENTATION_GAY Inmobi.CONSTANTS.SEXUAL_ORIENTATION_UNKNOWN

11

language

eng, tel, tam

Language has to be in the ISO-639-3 format. 12

postalCode

String

13

areaCode

String

14

interests

Comma-separated values

15

deviceIdMasks

iOS: Inmobi.CONSTANTS.EXCLUDE_VENDOR_ID

(array of values)

Inmobi.CONSTANTS.EXCLUDE_UDID Inmobi.CONSTANTS.EXCLUDE_ODIN1 Inmobi.CONSTANTS.EXCLUDE_FB_ATTR_ID Inmobi.CONSTANTS.EXCLUDE_ADVERTISER_ID

Android: Inmobi.CONSTANTS.EXCLUDE_UM5 Inmobi.CONSTANTS.EXCLUDE_ODIN1 Inmobi.CONSTANTS.EXCLUDE_FB_ATTR_ID

16

LocationInquiryAllowed

Android: Inmobi.CONSTANTS.TRUE

www.inmobi.com/support/art/23846096/22114287/appcelerator-partner-platform-integration-guide/

6/8

1/7/14

Article | InMobi Support Portal

Inmobi.CONSTANTS.TRUE Inmobi.CONSTANTS.FALSE

The deviceIdMasksare an array of exclusions. [ CONSTANTS.EXCLUDE_VENDOR_ID, Inmobi.CONSTANTS.EXCLUDE_ADVERTISER_ID ]

Using InMobi Analytics The Titanium InMobi module also brings you InMobi Analytics. There are five analytics methods that you can use to track user behaviour. startSessionManually Evoke startSessionwhen the application is launched. Do this before any other event is recorded, preferably in the onCreate()or onResumelifecycle methods of the launcher activity. The optional parameters will not be passed from iOS. Usage

Inmobi.analytics_startSessionManually(optionalParameters);

Example Inmobi.analytics_startSessionManually({"userId": "1234"});

endSessionManually Evoke endSessionwhen the app is closed, typically in onDestroy()or onPause(). The optional parameters will not be passed from iOS. Usage Inmobi.analytics_endSessionManually(optionalParameters);

Example Inmobi.analytics_endSessionManually({"userId": "1234"});

beginSection Evoke this event when the user has started viewing/playing a new section. This could be a tab or app content in the case of non-gaming apps. This could be a level in the case of gaming apps. Usage Inmobi.analytics_beginSection("sectionName", optionalParameters);

Example Inmobi.analytics_beginSection("home", {"user": "nkapser"});

endSection Evoke this event when a user has finished viewing/playing a section. Usage Inmobi.analytics_endSection("sectionName", optionalParameters);

Example Inmobi.analytics_endSection("sectionName", {});

tagEvent Use tagEventto record any arbitrary event that is not covered by the above APIs. Usage Inmobi.analytics_tagEvent("eventName", optionalParameters);

Example Inmobi.analytics_tagEvent("eventName", {});

www.inmobi.com/support/art/23846096/22114287/appcelerator-partner-platform-integration-guide/

7/8

1/7/14

Article | InMobi Support Portal

Quick Links

Developer Resources

Advertise

SDK Download Center

Monetize

Help Center

Products

Developer Center

Insights Company InMobi Blog InMobi Media Kits

Keep In Touch Facebook

Privacy Policy   |   Cookie Policy   |   Terms Learn more about ads (iab)

Linkedin Twitter

© 2013 InMobi

Vimeo Slideshare

www.inmobi.com/support/art/23846096/22114287/appcelerator-partner-platform-integration-guide/

8/8