All Projects → sakebook → Flutter_native_ads

sakebook / Flutter_native_ads

Licence: apache-2.0
Show AdMob Native Ads use PlatformView

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Flutter native ads

Media picker
A Flutter Plugin for Selecting and Taking New Photos and Videos.
Stars: ✭ 24 (-61.9%)
Mutual labels:  flutter-plugin
Nativescript Plugin Firebase
🔥 NativeScript plugin for Firebase
Stars: ✭ 990 (+1471.43%)
Mutual labels:  admob
Firebase auth ui
Flutter plugin for Firebase Auth UI. Supports popular auth providers by using native SDK for Android and iOS.
Stars: ✭ 44 (-30.16%)
Mutual labels:  flutter-plugin
Awesome Flutter
An awesome list that curates the best Flutter libraries, tools, tutorials, articles and more.
Stars: ✭ 38,582 (+61141.27%)
Mutual labels:  flutter-plugin
Leancloud flutter plugin
LeanCloud flutter plugin by Luna Gao
Stars: ✭ 34 (-46.03%)
Mutual labels:  flutter-plugin
Localize and translate
Flutter localization in easy steps, really simple
Stars: ✭ 40 (-36.51%)
Mutual labels:  flutter-plugin
Flutter foreground service plugin
Stars: ✭ 19 (-69.84%)
Mutual labels:  flutter-plugin
Flutterradioplayer
Flutter Radio Player, A Plugin to handle streaming audio without a hassle
Stars: ✭ 59 (-6.35%)
Mutual labels:  flutter-plugin
Flutter Contacts Plugin
Contact plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to read, create and update contacts from the address book.
Stars: ✭ 38 (-39.68%)
Mutual labels:  flutter-plugin
Flutter branch sdk
Flutter Plugin for create deep link using Brach Metrics SDK. This plugin provides a cross-platform (iOS, Android).
Stars: ✭ 43 (-31.75%)
Mutual labels:  flutter-plugin
Fluttertoast
Android Toast Plugin for Flutter
Stars: ✭ 957 (+1419.05%)
Mutual labels:  flutter-plugin
Flutter Unity View Widget
Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
Stars: ✭ 961 (+1425.4%)
Mutual labels:  flutter-plugin
Flutter wechat ble
ble 4.0 with wechat style api for flutter. flutter版微信api风格的低功耗蓝牙
Stars: ✭ 41 (-34.92%)
Mutual labels:  flutter-plugin
Flutter Cinema
Learn to create flutter app with BLoC Architecture
Stars: ✭ 26 (-58.73%)
Mutual labels:  flutter-plugin
Dlna Dart
A simple DLNA DMC library implemented by Dart.
Stars: ✭ 46 (-26.98%)
Mutual labels:  flutter-plugin
Drm wv fp player
Few of the resources from flutter plugin video_player
Stars: ✭ 19 (-69.84%)
Mutual labels:  flutter-plugin
Flutter orientation
A Flutter plugin for device's orientation
Stars: ✭ 39 (-38.1%)
Mutual labels:  flutter-plugin
Flutter svg
SVG parsing, rendering, and widget library for Flutter
Stars: ✭ 1,113 (+1666.67%)
Mutual labels:  flutter-plugin
Math Metrix
This is Math-Puzzle game made in flutter and available on Playstore & AppStore
Stars: ✭ 48 (-23.81%)
Mutual labels:  flutter-plugin
Fluttermidicommand
A Flutter plugin to send and receive MIDI
Stars: ✭ 41 (-34.92%)
Mutual labels:  flutter-plugin

flutter_native_ads

version

Flutter plugin for AdMob Native Ads. Compatible with Android and iOS using PlatformView.

Android iOS
image image

Getting Started

Android

AdMob 17 requires the App ID to be included in the AndroidManifest.xml. Failure to do so will result in a crash on launch of your app. The line should look like:

<meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="[ADMOB_APP_ID]"/>

where [ADMOB_APP_ID] is your App ID. You must pass the same value when you initialize the plugin in your Dart code.

iOS

Admob 7.42.0 requires the App ID to be included in Info.plist. Failure to do so will result in a crash on launch of your app. The lines should look like:

<key>GADApplicationIdentifier</key>
<string>[ADMOB_APP_ID]</string>

where [ADMOB_APP_ID] is your App ID. You must pass the same value when you initialize the plugin in your Dart code.

And PlatformView

<key>io.flutter.embedded_views_preview</key>
<true/>

Layout

This plugin supported custom layout. You need to create a layout file.

Android

You can use anything if the parent is a ViewGroup. The example uses ConstraintLayout.

Use com.google.android.gms.ads.formats.UnifiedNativeAdView for the parent.

image

Use com.google.android.gms.ads.formats.MediaView for MediaView.

image

  • xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.ads.formats.UnifiedNativeAdView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/flutter_native_ad_unified_native_ad"
    ...
    
    <!-- ViewGroup -->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/relativeLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        
        ...

        <com.google.android.gms.ads.formats.MediaView
            android:id="@+id/flutter_native_ad_media"
            ...

example

iOS

Please set GADUnifiedNativeAdView for the parent.

image

Please set GADMediaView to MediaView.

image

Please set Restoration ID for View that displays attribution

image

example

Mapping Native Ads to Layout

Need to mapping the view

Android

Mapping by view id

View ID
UnifiedNativeAdView flutter_native_ad_unified_native_ad
Headline flutter_native_ad_headline
Body flutter_native_ad_body
Call To Action flutter_native_ad_call_to_action
Attribution flutter_native_ad_attribution
MediaView flutter_native_ad_media
Icon flutter_naitve_ad_icon
Star rating flutter_naitve_ad_star
Store flutter_naitve_ad_store
Price flutter_naitve_ad_price
Advertiser flutter_naitve_ad_advertiser

iOS

Mapping by Outlet

image

Usage

import 'package:flutter/material.dart';
import 'package:native_ads/native_ad_param.dart';
import 'package:native_ads/native_ad_view.dart';

import 'package:native_ads/native_ads.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  NativeAds.initialize();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('NativeAds example app'),
        ),
        body: Center(
          child: ListView.separated(
            itemBuilder: (context, index) {
              if (index % 10 == 0) {
                return Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: SizedBox(
                    width: double.infinity,
                    height: 320,
                    child: NativeAdView(
                      onParentViewCreated: (_) {
                      },
                      androidParam: AndroidParam()
                        ..placementId = "ca-app-pub-3940256099942544/2247696110" // test
                        ..packageName = "{{YOUR_ANDROID_APP_PACKAGE_NAME}}"
                        ..layoutName = "{{YOUR_CREATED_LAYOUT_FILE_NAME}}"
                        ..attributionText = "AD"
                        ..testDevices = ["{{YOUR_TEST_DEVICE_IDS}}"],
                      iosParam: IOSParam()
                        ..placementId = "ca-app-pub-3940256099942544/3986624511" // test
                        ..bundleId = "{{YOUR_IOS_APP_BUNDLE_ID}}"
                        ..layoutName = "{{YOUR_CREATED_LAYOUT_FILE_NAME}}"
                        ..attributionText = "SPONSORED"
                        ..testDevices = ["{{YOUR_TEST_DEVICE_IDS}}"],
                      onAdImpression: () => print("onAdImpression!!!"),
                      onAdClicked: () => print("onAdClicked!!!"),
                      onAdFailedToLoad: (Map<String, dynamic> error) => print("onAdFailedToLoad!!! $error"),
                    ),
                  ),
                );
              } else {
                return Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text(
                    "this is text $index",
                    style: Theme.of(context).textTheme.body1,
                  ),
                );
              }
            },
            itemCount: 50,
            separatorBuilder: (context, _) => const Divider(),
          ),
        ),
      ),
    );
  }
}

Supported native ads fields

  • Headline(Required)
  • Body(Required)
  • Call To Action(Required)
  • Ad Attribution(Required)
  • Media
  • Icon
  • Star rating
  • Store
  • Price
  • Advertiser

Event callback

Receive callbacks for some events by passing to the NativeAdView constructor

  • onAdImpression
  • onAdClicked
  • onAdFailedToLoad
  • onAdLeftApplication
  • onAdLoaded

Reference

Limitations

This is just an initial version of the plugin. There are still some limitations:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].