⌨️SDK integration

Setup project

To integrate our SDK for Flutter, it is needed to add the following line inside the dependencies block of the pubspec.yaml file of your app:

dependencies:
  wortise: ^1.6.1

Next, execute the following command to proceed with the SDK installation:

$ flutter pub get

Now, you will be able to use the following import statements to access the classes provided by the SDK:

import 'package:wortise/ad_content_rating.dart';
import 'package:wortise/ad_settings.dart';
import 'package:wortise/ad_size.dart';
import 'package:wortise/banner_ad.dart';
import 'package:wortise/consent_manager.dart';
import 'package:wortise/data_manager.dart';
import 'package:wortise/interstitial_ad.dart';
import 'package:wortise/rewarded_ad.dart';
import 'package:wortise/user_gender.dart';
import 'package:wortise/wortise_sdk.dart';

Setup Manifest

To improve the eCPM of Google's Open Bidding partners, it is needed to add a <meta-data> element in the android/app/src/mainAndroidManifest.xml file, inside the <application> block.

This value can be found in our dashboard, inside the app details, under the name Google App ID.

<manifest>
    ...
    <application>
        ...
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
    </application>
</manifest>

It is very recommended to request the user consent to be able to show personalised ads. This will allow to display content of more interest and generate higher revenues.

You can consult the following section to implement this request and obtain the user consent: User consent

Initialize SDK

To initialize the SDK, it is needed to add the following code inside the initState() method of your app:

import 'package:wortise/wortise_sdk.dart';

await WortiseSdk.initialize('your app key');

Test mode

To verify the integration, the SDK provides a test mode that allows the app to always receive ads.

Beside the option that is available in our dashboard, you can programatically enable this test mode, from the SDK itself, by using the following code:

import 'package:wortise/ad_settings.dart';

await AdSettings.setTestEnabled(true);

Última actualización