refinery89_monetize_app 0.0.1-dev.3 refinery89_monetize_app: ^0.0.1-dev.3 copied to clipboard
The flutter plugin for the Refinery 89 Monetize App, supporting banner, outStream, interstitial (full-screen) and scrollable ads
Refinery89 Monetize App SDK #
This repository contains the source code for the Refinery89 Monetize App Flutter plugin, which enables publishers to monetize Flutter apps.
Get Started #
1. Add “Refinery89 Monetize App“ dependency by running
flutter pub add refinery89_monetize_app
2. Android Configuration
Prerequisites
- Use Android Studio 3.2 or higher.
- minSdkVersion of 19 or higher.
- compileSdkVersion of 28 or higher.
2.1 Gradle Dependencies
Add maven { url = uri("https://jitpack.io") }
to project level build.gradle:
allprojects {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
2.2 Add Google Ad ID to Manifext.xml
<manifest>
<application
...>
<!-- The value is the test id from Google ad manager docs -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value=<the-google-id>/>
...
<activity
...>
...
</activity>
</application>
</manifest>
Attention For countries that require to request CMP consent from users before displaying ads,
please add @style/Theme.AppCompat.NoActionBar
theme to the application
's theme
tag in the Manifest.xml file,
otherwise SDK will crash on initialization while trying to display CMP request activity.
<manifest>
<application
...
android:theme="@style/Theme.AppCompat.NoActionBar"
...>
...
</application>
</manifest>
-
Test: Use "ca-app-pub-3940256099942544~3347511713" for
-
Production: Use your own Google Id provided by us for
3. Flutter Configuration
3.1 On the Flutter side add the R89SDK.routeObserver to your Navigator
@override
Widget build(BuildContext context) {
return MaterialApp(
...
navigatorObservers: [
R89SDK.routeObserver,
],
...
);
}
3.2 Initialize the R89SDK in auto-config mode.
@override
void initState() {
super.initState();
R89SDK.setLogLevel(LogLevel.debug);
// With debug enabled the SDK will fetch the built-in mocked data for testing.
R89SDK.setDebug();
// auto-config initialization
R89SDK.initialize(
publisherId: "TestRefinery89ID",
appId: "TestAutoConfigDemoApp");
}
For manual-config initialization details check the example app.
4. Display Ads.
Flutter SDK supports the following ad formats
AdFormat.banner
Rectangular advertisements that remain visible on the screen during user interaction with the application, and have the ability to refresh automatically after a specified duration.AdFormat.videoOutStreamBanner
Video ads within a banner, that stay on the screen as users interact with the app, refreshing automatically after a certain period.AdFormat.interstitial
Full-screen ads that appear until the user closes. They're best used at natural pauses in the flow of an app's execution, such as in between levels of a game or screen-to-screen navigation.AdFormat.infiniteScroll
Ads load dynamically as users scroll through content, and dynamically display banner or videoOutStreamBanner ads based on the item's position within the scroll view.
4.1 Banner Ads
Use the R89Banner
widget to Display a banner ad.
@override
Widget build(BuildContext context) => Scaffold(
appBar: ...,
body: Column(children: [
...
R89Banner(
configurationId: ConfigBuilder.bannerTestR89ConfigId),
...
],),
);
4.2 OutStream Ads.
Use the R89OutStream
widget to Display a video ad.
@override
Widget build(BuildContext context) => Scaffold(
appBar: ...,
body: Column(children: [
...
R89OutStream(
configurationId: ConfigBuilder.videoOutStreamTestR89ConfigId),
...
],),
);
4.3 Interstitial Ads.
Use the createInterstitial
method from RefineryAdFactory
to display interstitial ads by providing the configurationId
R89SDK.adFactory.createInterstitial(
configurationId: ConfigBuilder.interstitialTestR89ConfigId);
4.4 Use the R89InfiniteScrollAd
widget to display ads by index in the scrollable widgets.
4.4.1 In the ListView's item add R89InfiniteScrollAd
as follows
Widget _buildItem(context, index) => Card(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Item index $index"),
),
Center(
child: R89InfiniteScrollAd(
itemIndex: index, infiniteScrollId: infiniteScrollId),
)
],
),
);
4.4.2 R89InfiniteScrollAd has two required parameters
- itemIndex the item position in the ListView
- infiniteScrollId is the R89SDK-generated scroll Id, which is shared between the child items of the same ListView.
Here is how to generate infiniteScrollId
final int infiniteScrollId = R89SDK.adFactory.createInfiniteScroll(
configurationId: ConfigConstants.infiniteScrollTestR89ConfigId);
4.4.3 The Full example for scrollable ads.
import 'package:flutter/material.dart';
import 'package:playground/config_constants.dart';
import 'package:refinery89_monetize_app/r89_sdk.dart';
class ScrollPage extends StatefulWidget {
const ScrollPage({super.key});
@override
State<ScrollPage> createState() => _ScrollPageState();
}
class _ScrollPageState extends State<ScrollPage> {
final int infiniteScrollId = R89SDK.adFactory.createInfiniteScroll(
configurationId: ConfigConstants.infiniteScrollTestR89ConfigId);
@override
Widget build(BuildContext context) => ListView.builder(
itemCount: 500,
itemBuilder: (context, index) => _buildItem(context, index),
);
Widget _buildItem(context, index) => Card(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Item index $index"),
),
Center(
child: R89InfiniteScrollAd(
itemIndex: index, infiniteScrollId: infiniteScrollId),
)
],
),
);
}
Support #
Feel free to reach out to our support team if you encounter any problems.