Appcelerator Integration for InMobi - Interface API Specification
This interface specification helps Appcelerator application developers to add InMobi banner and interstitial advertisements in their application using the InMobi Appcelerator module.
ti.inmobi.ad Module
Summary
Shows ads from InMobi.
Accessing the ti.inmobi.ad Module
Use the following method to access the module in JavaScript (app.js):
var imvar = require('ti.inmobi.ad');
Methods
createIMBannerAdView
Parameters
JSON Object
Summary
Creates and returns the IMBannerAd View object that displays ads.
createIMInterstitialAdView
Parameters
JSON Object
Summary
Creates and returns the IMInterstitialAd View object that displays ads.
createIMAdRequest
Parameters
JSON Object
Summary
Creates and returns the IMAdRequest object, which is used to send requests with a user-defined request parameter.
setLogLevel
Parameters
Integer
Summary
Possible values are:
1, 2, or 3 (default value is 1) – For iOS
- 1 – Minimal
- 2 – Debug
- 3 - Critical
Example:
imvar.setLogLevel(1)
- 1 and 0 – For Android
- 1 – logging ON
- 0 – logging OFF (default)
Note: App developers can also use setDebug(true) to enable module-level logging. By default, it is set to false.
Example:
imvar.setDebug (true)
ti.inmobi.ad.IMBannerAdView
Summary
IMBannerAdView is used to create banner advertisements in the application.
Example:
var imbanneradvar= imvar.createIMBannerAdView({imAppId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
adUnit:'INMOBI_AD_unit_320x50'});
Properties
imAppId
Type
String
Summary
This unique ID is required to make ad requests to the inMobi server. User can obtain appId under the Publisher section by logging into http://www.inmobi.com.
Note: This cannot be left blank. You get this ID when you register with InMobi.
adUnit
Type
String
Summary
The adUnit slot to request for the specific banner size.
-
INMOBI_AD_UNIT_320X48 -
INMOBI_AD_UNIT_300x250 -
INMOBI_AD_UNIT_728x90 -
INMOBI_AD_UNIT_468x60 -
INMOBI_AD_UNIT_120x600 -
INMOBI_AD_UNIT_320x50
refreshInterval
Type
Integer
Summary
This property sets the time duration after which banner makes a call for another advertisement request. Default value is 60 seconds.
Note: refreshInterval can not be less than 20 seconds. To turn refreshInterval off, set refreshInterval: -1
adViewReferenceTag
Type
String
Summary
This property is used to set a custom reference tag.
Note: When adViewReferenceTag is set, then you must set adViewReferenceTagForKey as well. Otherwise, the value will be ignored. (Specific to iOS)
adViewReferenceTagForKey
Type
String
Summary
This property is used to create a custom reference tag key.
Note: adViewReferenceTag and adViewReferenceTagForKey must be set together so that the value for adViewReferenceTagForKey is not ignored. (Specific to iOS)
animationType
Type
String
Summary
Sets the animation type for banner ad at UI level. For example, if animationType:’curlDown’, the banner ad comes with curl down animation whenever a new advertisement appears.
animationType can be one of the following:
- iOS Specific
-
curlUp(Default Value) -
curlDown -
flipFromLeft -
flipFromRight -
animationoff
-
- Android Specific
-
ANIMATION_OFF -
ROTATE_HORIZONTAL_AXIS -
ANIMATION_ALPHA -
ROTATE_VERTICAL_AXIS
-
top
Type
Integer
Summary
This property sets the top property or the Y-Coordinate of a banner ad.
left
Type
Integer
Summary
This property sets the left property or the X-Coordinate of a banner ad.
height
Type
Integer
Summary
This property sets the height of a banner ad.
Note: This value should be according to AdUnit. Please multiply with the density of the device to prevent the banner ad from being cropped.
width
Type
Integer
Summary
This property sets the width of banner ad.
Note: This value should be according to AdUnit. Please multiply with the density of the device to prevent the banner to be cropped.
imAdRequest
Type
Request Object
Summary
This property takes request object.
activity
Type
Activity
Summary
Android activity. It is optional. If not passed from titanium, SDK will internally use current activity.
Example:
activity:Titanium.Android.currentActivity
Events
onAdRequestCompleted
Callback object(s)
IMBannerAdView Object
Summary
This event will be fired when an ad request is completed.
onAdRequestFailed
Callback object(s)
Error Object
Summary
This event will be fired when an ad request is failed.
Key-Value pair object is obtained
- code - description
(iOS specific)
Only description is obtained as an object (Android specific)
adViewAfterDismissScreen
Callback object(s)
IMBannerAdView Object
Summary
This event will be fired just after dismissing a full screen view. (iOS Specific)
onDismissAdScreen
Callback object(s)
IMBannerAdView Object
Summary
This event will be fired just before dismissing a full screen view.
Caution: Do not use alert statements as it can hang the application.
onShowAdScreen
Callback object(s)
IMBannerAdView Object
Summary
This event will be fired just before the adview presents a full screen view to the user.
Caution: Do not use alert statements as it can hang the application.
onLeaveApplication
Callback object(s)
IMBannerAdView Object
Summary
This event will be fired just before the application runs in background because the user clicked on an ad that launchs another application (such as the App Store).
Caution: Do not use alert statements as it can hang the application.
Methods
loadNewAd
Parameter(s)
N.A.
Summary
Make a request to the inMobi Ad server to display new ad with previous request object set.
Example:
imbanneradvar.loadNewAd()
loadNewAdWithRequest
Parameter(s)
IMAdRequest object
Summary
Make a request to the inMobi Ad server to display new ad with new request object passed as parameter.
Example:
imbanneradvar.loadNewAdWithRequest(request).
addIMAdRequest
Parameter(s)
IMAdRequest object
Summary
User can create the request object explicitly and pass it as a parameter to this method to make ad request.
Example:
imbanneradvar.addIMAdRequest(request)
ti.inmobi.ad.IMInterstitialAdView
Summary
IMInterstitialAdView is used to show Interstitial Ad View.
Example:
var iminteradvar= imvar.createIMInterstitialAdView({imAppId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'});
Properties
activity
Type
Activity
Summary
Android activity. If not passed inline, load method needs to be called with activity.
Example:
activity:Titanium.Android.currentActivity
imAppId
Type
String
Summary
This is a unique ID that will be required when to make ad request to the inMobi server. User can obtain appId under the Publisher section by logging into http://www.inmobi.com.
Note: This must not be blank.
imAdRequest
Type
IMAdRequest Object
Summary
Request object. (iOS Specific)
Events
onAdRequestLoaded
Callback object(s)
IMInterstitialAdView Object
Summary
This event will be fired when an interstitial ad request succeeded.
onAdRequestFailed
Callback object(s)
Error object
Summary
This event will be fired when an interstitial ad request failed. Key-Value pair
- code
- description
(iOS Specific)
- errorCode
(Android Specific)
onShowAdScreen
Callback object(s)
IMInterstitialAdView Object
Summary
This event will be fired just before presenting an interstitial ad. After this event finishes, the interstitial will animate on to the screen.
Caution: Do not use alert statements as it can hang the application.
didFailToPresentScreen
Callback object(s)
Error object
Summary
Sent when an interstitial fails to present a full screen to the user. This will generally occur if interstitial is not in a ready state.
Key-Value pair object
- code
- description
Caution: Do not use alert statements as it can hang the application. (iOS Specific)
onDismissAdScreen
Callback object(s)
IMInterstitialAdView Object
Summary
This event will be fired before the interstitial is to be animated off the screen.
Caution: Do not use alert statements as it can hang the application.
interstitialDidDismissScreen
Callback object(s)
IMInterstitialAdView Object
Summary
This event will be fired just after dismissing an interstitial and it has animated off the screen.
Caution: Do not use alert statements as it can hang the application. (iOS Specific)
onLeaveApplication
Callback object(s)
IMInterstitialAdView Object
Summary
This event will be fired just before the application goes to the background because the user clicked on an ad that will launch another application (such as the App Store).
Caution: Do not use alert statements as it can hang the application.
Methods
loadNewAd
Parameter(s)
Request object
Summary
Makes a request to the inMobi Ad server to refresh ad request.
In iOS, request object is optional. In Android, it is mandatory
Load
Parameter(s)
Activity Object
Summary
This method is used to pass activity to interstitial view. This is a mandatory call if the activity is not passed inline while creating the interstitial object. (Android Specific)
Show
Parameter(s)
N.A.
Summary
This method displays the ad, if it is in ready state.
getState
Parameter(s)
N.A.
Summary
This method returns the state of the interstitial ad. This method can return one of the following states:
- INIT
- READY
- LOADING
- ACTIVE
ti.inmobi.ad.IMAdRequest
Summary
Developer can explicitly create object of IMAdRequest and set it as request object for displaying ad.
Example:
var imrequestvar= imvar.createIMAdRequest();
Properties
testMode
Type
Boolean
Summary'
To set the test mode on or off.
Default value: false
education
Type
String
Summary
Education value which should be among following values:
- EDU_BACHELORSDEGREE
- EDU_MASTERSDEGREE
- EDU_DOCTORALDEGREE
- EDU_HIGHSCHOOL
- EDU_INCOLLEGE
- EDU_OTHER
- EDU_NONE
- EDU_SOMECOLLEGE ( Android Specific)
interests
Type
String
Summary
Interest and hobbies.
postalCode
Type
String
Summary
Postal code.
areaCode
Type
String
Summary
Area code.
dateOfBirth
Type
String
Summary
Date of birth.
Note: It should be in dd-mm-yyyy format.
keywords
Type
String
Summary
Use contextually relevant strings to deliver more relevant ads. For example, "offers sale shopping".
Income
Type
Integer
Summary
Income.
searchString
Type
String
Summary
Search string provided by the user. For example, "Hotel Bangalore India".
Age
Type
Integer
Summary
Age.
ethnicity
Type
String
Summary
Ethnicity.
This could be one of the following:
- Eth_None
- Eth_Mixed
- Eth_Asian
- Eth_Black
- Eth_Hispanic
- Eth_NativeAmerican
- Eth_White
- Eth_Other
deviceIDMask
Type
String
Summary
This could be one of the following
- ID_DEVICE_NONE
- ID_DEVICE_ODIN_1
(iOS Specific)
Gender
Type
String
Summary
Sex.
This could be one of the following:
- MALE
- FEMALE
- NONE
requestParams
Type
JSON Object
Summary
Provide additional values to be passed in the ad request as key-value pair.
Example:
requestParams:{param1:”value1”,param2:”value2”}
locationInquiryAllowed
Type
Boolean
Summary
This property defines your locationInquiryAllowed. (Android Specific)
cityLocation
Type
- String (iOS)
- Array (Android)
Summary
For internal purpose.
Example:
- cityLocation:”Noida” (iOS)
- cityLocation: new Array(“Noida”,”UP”,”India”) (Android)
loginID
Type
String
Summary
Login-id value. (iOS Specific)
sessionID
Type
String
Summary
The session-id value. (iOS Specific)
currentLocation
Type
JSON object
Summary
Use this property to set the user's current location to deliver more relevant ads.
Example:
currentLocation:{"provider":{"name":"gps"}, "coords":{"longitude":77,"latitude":28,"speed":0,"accuracy":0,"altitude":0}
Note: JSON format should be used as above, where longitude & latitude values are mandatory.
City
Type
String
Summary
Locality based ad targeting. (iOS Specific)
State
Type
String
Summary
Locality based ad targeting. (iOS Specific)
country
Type
String
Summary
Locality based ad targeting. (iOS Specific)