-
Notifications
You must be signed in to change notification settings - Fork 69
ANJAM User Guide
To allow mobile creatives running within the AppNexus SDK to access additional features that are not available in MRAID.
All ANJAM functions are asynchronous. Any function which queries for a result will need to provide a function to handle the response. The provided callback function will be called with a result object whose properties contain the results of the query. Note that all result objects will also contain a result.caller property with the value of the calling function's name (for example "MayDeepLink", or "GetDeviceID").
#ANJAM Functions
##anjam.MayDeepLink(url, result_callback)
Creatives may use this function to determine whether there is an app installed on the phone/tablet that would support the passed in 'deep link' URL. The determination of whether the URL will or won't be handled by an external application is a function of the underlying operating system.
url
- is a string indicating a deep link URL that is handled by a native app. For example, fb://post?1234
.
Facebook documentation on deep linking is available at https://developers.facebook.com/docs/ios/app-links/.
result_callback
- function(result){}
Will be called with a result object, with a value of true or false in the result.mayDeepLink property indicating wether the deep link will be handled on this device or not.
##anjam.DeepLink(url, err_callback)
Creatives will use this function to call the deep link URL, usually as a response to an onClick()
event or after receiving a True result from MayDeepLink()
. If the launch is successful, the linked app will launch and the error callback function will not be called. If the advertisement was in an expanded state the ad will close, and return to its unexpanded state when the user returns to the current application.
url
- Is a string indicating th deep link to launch.
err_callback
- function(result){}
Called only if the DeepLink
launch operation was unsuccessful. The result object is only useful for the result.caller property. If the err_callback
is invoked, then the call failed.
##anjam.ExternalBrowser(url)
Allows the creative to override the SDK configuration and force the landing page to open in the device's native browser (contrary to the default in-app browser). This will override the developer settings on the view object rendering the current creative.
url
- A URL to open in the native platform browser. Similar to the DeepLink
call, but meant for launching web sites in the native browser such as Safari or Chrome. This is why there is no error callback as in DeepLink
.
##anjam.InternalBrowser(url)
URLs are normally opened within the in app browser by the SDK in an invisible mode to check whether the URL redirects to a store or not. The anjam.InternalBrowser call enforces the in-app browser to become immediately visible. If the URL or one of its redirects goes to the app store, the app store will be opened and the in-app browser destroyed as normal. This method is intended for allowing a creative to override the initial invisible mode.
url
- A URL to open within the in-app browser.
##anjam.RecordEvent(url)
Used for tracking events; the URL will be loaded by the SDK in the background. This is usually used for tracking pixels.
url
- the URL the SDK will load in the background. The URL will accept 'data' URLs or 'javascript:'
##anjam.DispatchAppEvent(event, data)
Ability for the creative to send a custom event to the app. To receive this event, the app must implement code. On iOS, the application would have implemented ANAppEventDelegate's didReceiveAppEvent method. On Android, the application would implement the onAppEvent in the AppEventListener class.
event
- a string delivered to the app's handler.
data
- a string delivered to the app's handler.
##anjam.GetVersion(callback)
Used to get the current version of the ANJAM API.
callback
- function(result){}
Called with the current API version string ("1.0") in the result.version property.
##anjam.GetDeviceID(callback)
Used to retrieve the current device ID for Advertising.
callback
- function(result){}
Called with the result.idname and result.id properties. idname is a string with the type of ID being passed, id is the string value of the advertising ID.
- For iOS devices, `idname` will be 'idfa' and `id` is the Apple ID For Advertising.
- For Android devices using the Google Play services, `idname` will be 'aaid' and the `id` will be the Google Android Advertising ID.
- For Android devices not using Google Play services, `idname` will be 'sha1udid` and the `id` will be the SHA1 hash of the device's Android ID.