About Apester's In-App Android Script
The regular Javascrip embed code of a unit, once added to the article or webpage in your CMS will also work in In-App Android. The same is true for a header tag and playlist integration.
However, if you are an Apester monetisation partner, to earn an income on your Androind in-app traffic you'll need the below Apester script to your app. All the scrip does is enable Apester to fetch the Google's Advertising ID (AID) and pass it on to our ad demand partners.
Script Installation
Step 1
Create a custom class that contains the methods you want to call from JavaScript. The following code example shows a class that gets the Google AID, isLimitAdTrackingEnabled and the application identifier setting:
import com.google.android.gms.ads.identifier.AdvertisingIdClient; import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info ; public class CustomNativeAccess { private final Context mContext; private String gaid; private boolean isLAT; public CustomNativeAccess (Context context) { mContext = context; new Thread( new Runnable() { @Override public void run () { Info adInfo = null ; try { adInfo = AdvertisingIdClient.getAdvertisingIdInfo(mContext); gaid = adInfo.getId(); isLAT = adInfo.isLimitAdTrackingEnabled(); packageName = mContext.getPackageName(); } catch (Exception e) { } } }).start(); } @JavascriptInterface public String getGaid () { return gaid; } @JavascriptInterface public String getPackageName () { return packageName; } @JavascriptInterface public boolean getIsLAT () { return isLAT; } }
Step 2
In your main activity, instantiate the class and add it to the WebView with AddJavascriptInterface before displaying your html, passing it the name of the interface that you use to access it in the JavaScript.
public class NativeToJSExampleActivity extends Activity { @Override public void onCreate (Bundle savedInstanceState) { super .onCreate(savedInstanceState); // Create a WebView or grab your existing one before this step yourWebView.addJavascriptInterface( new CustomNativeAccess( this ), "apesterData" ); } }
Now that you've passed the interface as "apesterData" you need to run this Javascript to send these parameters to our SDK:
Comments
0 comments
Please sign in to leave a comment.