Before You Start Make Sure:
Initialise the SDK upon app start. In order to do so - within your app's main activity onCreate() method call the SDK’s Controller.init(Context activity, InitProperties properties, String appId) method, after you have called setContentView().
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Controller ctrl = Controller.getInstance();
if (!ctrl.isInitialized()) {
ctrl.setSdkInitListener(new SdkInitListener() {
@Override
public void onInit() {
// integration code
}
@Override
public void onInitError(DIOError error) {
// integration code
}
});
ctrl.init(MainActivity.this, initProperties, <Your App Id>);
}
}
Note:
You can find your App ID in your Account on the Developer Portal (Applications tab).
Important:
Do not try to initialise Controller more than once. Always validate if (!ctrl.isInitialized()) {....} before calling init().
We highly recommend to set InitProperties object in order to provide more info for better ad targeting:
InitProperties initProperties = new InitProperties();
//provide additional ad attributes -
//'Advertiser Name' and 'Advertiser Click URL'
initProperties.setDetailsRequired(false);
// set user gender
initProperties.setGender(InitProperties.MALE);
// set user year of birth
initProperties.setYearOfBirth(1999);
// set user keywords
List<String> keywords = new ArrayList<>();
keywords.add("house of cards");
keywords.add("ronaldo");
initProperties.setKeywords(keywords);
// set if the user is a child, according to the local law
// (UNKNOWN (default), YES, NO)
initProperties.setChildCompliant(CompliantState.NO);
As a best practice, we advise our publishers to add as much user data to their ad requests as possible. The reason for that is that it gives advertisers visibility into the parameters of each user within your app and allows advertisers to bid more intelligently, meaning a higher CPM payout for developer.
Additional: Starting Android Pie (API 28), Google isn't allowing using a single WebView instance in 2 different processes, so in case you are using multiple processes in your application, you have to call WebView.setDataDirectorySuffix("dir_name_no_separator"), according to documentation. We also provide opportunity to handle this inside SDK, what you need is to notify Controller object about it before call init:
ctrl.setMultipleProcessApp(true);
Comments
0 comments
Please sign in to leave a comment.