Coder Social home page Coder Social logo

sakebook / flutter_native_ads Goto Github PK

View Code? Open in Web Editor NEW
66.0 6.0 32.0 10.67 MB

Show AdMob Native Ads use PlatformView

Home Page: https://pub.dev/packages/native_ads

License: Apache License 2.0

Kotlin 27.10% Ruby 13.19% Swift 22.94% Objective-C 1.14% Dart 35.63%
flutter-plugin admob platform-view flutter native-ads android ios

flutter_native_ads's Introduction

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:

flutter_native_ads's People

Contributors

sakebook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter_native_ads's Issues

java.lang.NoSuchMethodError: No virtual method getMediaContent()

E/AndroidRuntime( 5612): java.lang.NoSuchMethodError: No virtual method getMediaContent() Lcom/google/android/gms/ads/formats/UnifiedNativeAd$MediaContent; in class Lcom/google/android/gms/ads/formats/UnifiedNativeAd; or its super classes (declaration of 'com.google.android.gms.ads.formats.UnifiedNativeAd' appears in /data/app/com--------------------------==/base.apk) E/AndroidRuntime( 5612): at sakebook.github.com.native_ads.UnifiedAdLayout.ensureUnifiedAd(UnifiedAdLayout.kt:94) E/AndroidRuntime( 5612): at sakebook.github.com.native_ads.UnifiedAdLayout.access$ensureUnifiedAd(UnifiedAdLayout.kt:18) E/AndroidRuntime( 5612): at sakebook.github.com.native_ads.UnifiedAdLayout$2.onUnifiedNativeAdLoaded(UnifiedAdLayout.kt:44) E/AndroidRuntime( 5612): at com.google.android.gms.internal.ads.zzafe.zza(com.google.android.gms:play-services-ads-lite@@19.1.0:6) E/AndroidRuntime( 5612): at com.google.android.gms.internal.ads.zzbzm.zzakv(com.google.android.gms:play-services-ads@@19.1.0:179) E/AndroidRuntime( 5612): at com.google.android.gms.internal.ads.zzbzp.run(Unknown Source:2) E/AndroidRuntime( 5612): at android.os.Handler.handleCallback(Handler.java:789) E/AndroidRuntime( 5612): at android.os.Handler.dispatchMessage(Handler.java:98) E/AndroidRuntime( 5612): at com.google.android.gms.internal.ads.zzdns.zzb(com.google.android.gms:play-services-ads-lite@@19.1.0:9) E/AndroidRuntime( 5612): at com.google.android.gms.internal.ads.zzawu.zzb(com.google.android.gms:play-services-ads@@19.1.0:8) E/AndroidRuntime( 5612): at com.google.android.gms.internal.ads.zzdns.dispatchMessage(com.google.android.gms:play-services-ads-lite@@19.1.0:7) E/AndroidRuntime( 5612): at android.os.Looper.loop(Looper.java:164) E/AndroidRuntime( 5612): at android.app.ActivityThread.main(ActivityThread.java:6541) E/AndroidRuntime( 5612): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 5612): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) E/AndroidRuntime( 5612): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Can't load Ads and event callback not showing anything (Android)

Hi,

I place native ads widget on my Home Screen and the structure like below:

For Initialization:

class HomeScreen extends StatefulWidget{
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> with AfterLayoutMixin<HomeScreen> {

  @override
    void initState() {
      // TODO: implement initState
      super.initState();      
      NativeAds.initialize();
      ...
    }

For NativeAds placement is under below structures:

@override
Widget build(BuildContext context) {
  return Stack(
    children: <Widget>[
      Scaffold(
        appBar: AppBar( .. ),
        body: OfflineBuilder(
              connectivityBuilder: (BuildContext context, ConnectivityResult connectivity, Widget child) {
                  ...  
                  child: NestedScrollView(
                      headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { ... }
                      body: RefreshIndicator(
                        backgroundColor: Pigment.fromString(UIData.primaryColor),
                        color: Colors.white,
                        onRefresh: () => homeBloc.init(),
                        child: ListView(
                          children: <Widget>[
                            Row(
                            ...
                              ListView(
                                physics: NeverScrollableScrollPhysics(),
                                shrinkWrap: true,
                                children: <Widget>[
                                 
                                ...

                                  
                                SizedBox(
                                  width: double.infinity,
                                  height: 320,
                                  child: NativeAdView(
                                    onParentViewCreated: (_) {
                                      print("sinative create.....");
                                    },
                                    androidParam: AndroidParam()
                                      ..placementId = "ca-app-pub-xxx" //my admob
                                      ..packageName = "com.apps.myapp"
                                      ..layoutName = "native_ad_layout"
                                      ..attributionText = "AD",
                                    iosParam: IOSParam()
                                      ..placementId = "ca-app-pub-3940256099942544/3986624511" // test
                                      ..bundleId = "{{YOUR_IOS_APP_BUNDLE_ID}}"
                                      ..layoutName = "{{YOUR_CREATED_LAYOUT_FILE_NAME}}"
                                      ..attributionText = "SPONSORED",
                                    onAdImpression: () => print("sinative_muncul"),
                                    onAdClicked: () => print("onAdClicked!!!"),
                                    onAdFailedToLoad: (Map<String, dynamic> error) => print("sinative_error ==> $error"),
                                  ),
                                ),                      
                                
                                ...

                                ...


However, Native Ads wont load and show, also the event callback like onAdFailedToLoad does not return anything...

any idea to solve ?

Thank You in advance...

App Crash after add native_ads: ^0.3.0 in pubspec.yaml while opening

I running my app well, no ads here,
and then I add native_ads: ^0.3.0 in pubspec.yaml , run packages get ,and try rebuild my app to run.
but it crash on opening , even not show the opening page.

flutter doctor -v

[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G95, locale zh-Hans-CN)
• Flutter version 1.9.1+hotfix.6 at /Volumes/Jianan/SDK/flutter
• Framework revision 68587a0916 (3 months ago), 2019-09-13 19:46:58 -0700
• Engine revision b863200c37
• Dart version 2.5.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Volumes/Jianan/SDK/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
• Xcode at /Volumes/Jianan/APP/Xcode.app/Contents/Developer
• Xcode 11.1, Build version 11A1027
• CocoaPods version 1.8.3

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[!] IntelliJ IDEA Ultimate Edition (version 2018.1.5)
• IntelliJ at /Applications/IntelliJ IDEA.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins

[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.0 (API 24) (emulator)

! Doctor found issues in 2 categories.

onAdFailedToLoad!!! {errorCode: 3}

√ Built build\app\outputs\apk\debug\app-debug.apk.
D/FlutterActivity(25192): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate(25192): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate(25192): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
D/FlutterActivityAndFragmentDelegate(25192): Attaching FlutterEngine to the Activity that owns this Fragment.
D/FlutterView(25192): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@60eba24
D/FlutterActivityAndFragmentDelegate(25192): Executing Dart entrypoint: main, and sending initial route: /
Syncing files to device AOSP on IA Emulator...
D/EGL_emulation(25192): eglMakeCurrent: 0xdf4051e0: ver 2 0 (tinfo 0xdf403660)
I/utideas.diyjav(25192): The ClassLoaderContext is a special shared library.
I/utideas.diyjav(25192): The ClassLoaderContext is a special shared library.
D/eglCodecCommon(25192): setVertexArrayObject: set vao to 0 (0) 1 0
I/utideas.diyjav(25192): The ClassLoaderContext is a special shared library.
I/DynamiteModule(25192): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21200
I/DynamiteModule(25192): Selected remote version of com.google.android.gms.ads.dynamite, version >= 21200
D/DynamitePackage(25192): Instantiated singleton DynamitePackage.
D/DynamitePackage(25192): Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
D/NetworkSecurityConfig(25192): No Network Security Config specified, using platform default
I/WebViewFactory(25192): Loading com.android.chrome version 69.0.3497.100 (code 349710017)
I/utideas.diyjav(25192): The ClassLoaderContext is a special shared library.
I/cr_LibraryLoader(25192): Time to load native libraries: 32 ms (timestamps 3533-3565)
E/cr_VariationsUtils(25192): Failed reading seed file "/data/user/0/com.tutideas.diyjava/app_webview/variations_seed": /data/user/0/com.tutideas.diyjava/app_webview/variations_seed (No such file or directory)
I/chromium(25192): [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_LibraryLoader(25192): Expected native library version number "69.0.3497.100", actual native library version number "69.0.3497.100"
W/cr_ChildProcLH(25192): Create a new ChildConnectionAllocator with package name = com.android.chrome, sandboxed = true
I/cr_BrowserStartup(25192): Initializing chromium process, singleProcess=false
I/utideas.diyjav(25192): Background concurrent copying GC freed 16356(1761KB) AllocSpace objects, 11(240KB) LOS objects, 49% free, 2MB/4MB, paused 6.787ms total 273.730ms
W/utideas.diyjav(25192): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->(Landroid/content/Context;I)V (light greylist, reflection)
W/utideas.diyjav(25192): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (light greylist, reflection)
W/utideas.diyjav(25192): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/utideas.diyjav(25192): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/utideas.diyjav(25192): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/utideas.diyjav(25192): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/utideas.diyjav(25192): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/utideas.diyjav(25192): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/cr_media(25192): Requires BLUETOOTH permission
D/HostConnection(25192): HostConnection::get() New Host Connection established 0xdf423d10, tid 25265
D/HostConnection(25192): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
E/chromium(25192): [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_SUCCESS
W/cr_CrashFileManager(25192): /data/user/0/com.tutideas.diyjava/cache/WebView/Crash Reports does not exist or is not a directory
D/eglCodecCommon(25192): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(25192): eglCreateContext: 0xdf407b80: maj 2 min 0 rcv 2
D/EGL_emulation(25192): eglMakeCurrent: 0xdf407b80: ver 2 0 (tinfo 0xc147f9b0)
W/VideoCapabilities(25192): Unrecognized profile 4 for video/hevc
I/VideoCapabilities(25192): Unsupported profile 4 for video/mp4v-es
W/cr_MediaCodecUtil(25192): HW encoder for video/avc is not available on this device.
E/chromium(25192): [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_SUCCESS
D/eglCodecCommon(25192): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(25192): eglCreateContext: 0xb749b960: maj 2 min 0 rcv 2
D/EGL_emulation(25192): eglMakeCurrent: 0xb749b960: ver 2 0 (tinfo 0xc147f9b0)
D/eglCodecCommon(25192): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(25192): setVertexArrayObject: set vao to 2 (2) 0 0
D/eglCodecCommon(25192): setVertexArrayObject: set vao to 1 (1) 0 0
E/utideas.diyjav(25192): Invalid ID 0x00000000.
E/MethodChannel#flutter/platform_views(25192): Failed to handle method call
E/MethodChannel#flutter/platform_views(25192): android.content.res.Resources$NotFoundException: Resource ID #0x0
E/MethodChannel#flutter/platform_views(25192): at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
E/MethodChannel#flutter/platform_views(25192): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2155)
E/MethodChannel#flutter/platform_views(25192): at android.content.res.Resources.getLayout(Resources.java:1155)
E/MethodChannel#flutter/platform_views(25192): at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
E/MethodChannel#flutter/platform_views(25192): at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
E/MethodChannel#flutter/platform_views(25192): at android.view.View.inflate(View.java:24354)
E/MethodChannel#flutter/platform_views(25192): at sakebook.github.com.native_ads.UnifiedAdLayout.(UnifiedAdLayout.kt:22)
E/MethodChannel#flutter/platform_views(25192): at sakebook.github.com.native_ads.UnifiedAdLayoutFactory.create(UnifiedAdLayoutFactory.kt:11)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.plugin.platform.SingleViewPresentation.onCreate(SingleViewPresentation.java:174)
E/MethodChannel#flutter/platform_views(25192): at android.app.Dialog.dispatchOnCreate(Dialog.java:407)
E/MethodChannel#flutter/platform_views(25192): at android.app.Dialog.show(Dialog.java:302)
E/MethodChannel#flutter/platform_views(25192): at android.app.Presentation.show(Presentation.java:249)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.plugin.platform.VirtualDisplayController.(VirtualDisplayController.java:93)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:53)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:105)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:96)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#flutter/platform_views(25192): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#flutter/platform_views(25192): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter/platform_views(25192): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#flutter/platform_views(25192): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#flutter/platform_views(25192): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#flutter/platform_views(25192): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views(25192): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#flutter/platform_views(25192): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter (25192): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Resource ID #0x0, null)
E/flutter (25192): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (25192): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter (25192):
E/flutter (25192): #2 AndroidViewController._create (package:flutter/src/services/platform_views.dart:640:54)
E/flutter (25192): #3 AndroidViewController.setSize (package:flutter/src/services/platform_views.dart:557:14)
E/flutter (25192): #4 RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:174:29)
E/flutter (25192): #5 RenderAndroidView.performResize (package:flutter/src/rendering/platform_view.dart:155:5)
E/flutter (25192): #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1703:9)
E/flutter (25192): #7 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #9 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:259:13)
E/flutter (25192): #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #11 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:206:11)
E/flutter (25192): #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #13 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:744:15)
E/flutter (25192): #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #15 RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:392:13)
E/flutter (25192): #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #17 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:163:11)
E/flutter (25192): #18 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:477:7)
E/flutter (25192): #19 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:232:7)
E/flutter (25192): #20 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:391:14)
E/flutter (25192): #21 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #22 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #23 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #24 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #25 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1232:11)
E/flutter (25192): #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #27 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #28 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #29 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #31 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #33 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #35 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #36 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #37 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #38 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #39 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #40 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
E/flutter (25192): #41 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
E/flutter (25192): #42 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3168:13)
E/flutter (25192): #43 RenderObject.layout (package:flutt

no icon

Hi, can you add icon support ?

iOS Not all asset views lie inside the native ad view

Ads are working on our iOS device. We are getting this error message in the debug log. Not sure if we are causing this or if it is from the plugin:

Google:HTML Not all asset views lie inside the native ad view. This indicates an integration problem. Such implementations will not be supported in the future. Please make sure that all native ad assets are rendered inside the native ad view.

Native ad breaks layout in a list view in iOS

Hi,

I'm loading a Native Ad in a list view inside a view pager, when the ad is loading everything seems to work fine, but after the ad is loaded it creates some weird behavior.
A Banner ad (which is an overlay, from 'firebase_admob') becomes hidden below the layout and scrolling isn't working properly.

What can I do to fix this?
Simulator Screen Shot - iPhone 11 Pro Max - 2020-04-05 at 06 57 03

Simulator Screen Shot - iPhone 11 Pro Max - 2020-04-05 at 07 05 14

Release Build Crash, NULL POINTER EXCEPTION : UnifiedAdLayout

`java.lang.NullPointerException:

at com.google.android.gms.ads.internal.activeview.ac. (ac.java:4)

at com.google.android.gms.ads.nonagon.ad.event.db.a (db.java:1)

at com.google.android.gms.ads.nonagon.ad.nativead.r.a (r.java:86)

at com.google.android.gms.ads.nonagon.ad.nativead.ai.a (ai.java:18)

at com.google.android.gms.ads.nonagon.ad.nativead.bh.a (bh.java:18)

at com.google.android.gms.ads.internal.formats.client.k.a (k.java:27)

at ff.onTransact (ff.java:4)

at android.os.Binder.transact (Binder.java:507)

at com.google.android.gms.internal.ads.zzgc.zza (zzgc.java)

at com.google.android.gms.internal.ads.zzaco.zza (zzaco.java)

at com.google.android.gms.ads.formats.UnifiedNativeAdView.setNativeAd (UnifiedNativeAdView.java)

at sakebook.github.com.native_ads.UnifiedAdLayout.access$ensureUnifiedAd (UnifiedAdLayout.java)

at sakebook.github.com.native_ads.UnifiedAdLayout.access$getMethodChannel$p (UnifiedAdLayout.java)

at sakebook.github.com.native_ads.UnifiedAdLayout.ensureUnifiedAd (UnifiedAdLayout.java)

at sakebook.github.com.native_ads.UnifiedAdLayout.onFlutterViewAttached (UnifiedAdLayout.java)

at sakebook.github.com.native_ads.UnifiedAdLayout.access$ensureUnifiedAd (UnifiedAdLayout.java)

at sakebook.github.com.native_ads.UnifiedAdLayout.access$getMethodChannel$p (UnifiedAdLayout.java)

at sakebook.github.com.native_ads.UnifiedAdLayout.ensureUnifiedAd (UnifiedAdLayout.java)

at sakebook.github.com.native_ads.UnifiedAdLayout.onFlutterViewAttached (UnifiedAdLayout.java)

at sakebook.github.com.native_ads.UnifiedAdLayout$2.onUnifiedNativeAdLoaded (UnifiedAdLayout.java)

at com.google.android.gms.internal.ads.zzaer.zza (zzaer.java)

at com.google.android.gms.internal.ads.zzady.zza (zzady.java)

at com.google.android.gms.internal.ads.zzady.zzv (zzady.java)

at com.google.android.gms.internal.ads.zzgb.onTransact (zzgb.java)

at android.os.Binder.transact (Binder.java:507)

at fe.b (fe.java:2)

at com.google.android.gms.ads.internal.formats.client.aw.a (aw.java)

at com.google.android.gms.ads.nonagon.ad.nativead.ae.run (ae.java:7)

at android.os.Handler.handleCallback (Handler.java:751)

at android.os.Handler.dispatchMessage (Handler.java:95)

at oz.a (oz.java)

at com.google.android.gms.ads.internal.util.f.a (f.java:1)

at oz.dispatchMessage (oz.java)

at android.os.Looper.loop (Looper.java:154)

at android.app.ActivityThread.main (ActivityThread.java:6776)

at java.lang.reflect.Method.invoke (Method.java)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1496)

at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1386)`

Layout is not visible on Release build

Shows container instead of layout,but debugging one is showing well.
Created my own layouts and also tested your Example code,but nothing is showing in release mode

Apple will stop accepting submissions of apps that use UIWebView APIs.

Getting the following message submitting our app to Apple App Store:

ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs . After you’ve corrected the issues, you can use Xcode or Application Loader to upload a new binary to App Store Connect.

This is a known issue with the ADMob iOS SDK: https://groups.google.com/forum/#!topic/google-admob-ads-sdk/QuZMbjIyxn8

It looks like this has been resolved in the 7.50 SDK.

Ios UIKitView Click Area Issue

Duplicate click events while using UIKitView.

Here's how it's reproduced. When you place a native ad in the widget, use Drawer, and click where the ad is located to move to a screen such as "Navigator.push()" the url will launch.

In addition, the same thing happens when you try to move a screen by attaching a widget such as "GestureDetector" over a native ad.

Below is a code that can reproduce the problem.

class TextPage extends StatefulWidget {
@OverRide
_TextPageState createState() => _TextPageState();
}

class _TextPageState extends State {

@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
drawer: Drawer(child: Column(
children: [
CupertinoButton(
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context){
return Center(child: Container(color: Colors.red,));
}));
},
child: Container(height: 100,color: LocalizedStrings.next()),
),
CupertinoButton(
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context){
return Center(child: Container(color: Colors.red,));
}));
},
child: Container(height: 100,color: LocalizedStrings.next()),
),
CupertinoButton(
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context){
return Center(child: Container(color: Colors.red,));
}));
},
child: Container(height: 100,color: LocalizedStrings.next()),
),
CupertinoButton(
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context){
return Center(child: Container(color: Colors.red,));
}));
},
child: Container(height: 100,color: LocalizedStrings.next()),
),
CupertinoButton(
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context){
return Center(child: Container(color: Colors.red,));
}));
},
child: Container(height: 100,color: LocalizedStrings.next()),
),
],
),),
appBar: AppBar(
title: const Text('NativeAds example app'),
),
body: Center(
child: Container(
height: ScreenUtil().setWidth(600), child: NativeAdView(
androidParam: AndroidParam()
..placementId = "" // test
..packageName = ""
..layoutName = ""
..attributionText = "AD",
iosParam: IOSParam()
..placementId = "ca-app-pub-3940256099942544/3986624511" // test
..bundleId = "com.dubberss.koo.dub2"
..layoutName = "UnifiedNativeAdView"
..attributionText = "AD",
onAdImpression: () => print("onAdImpression!!!"),
onAdClicked: () => print("onAdClicked!!!"),
onAdFailedToLoad: (Map<String, dynamic> error) =>
print("onAdFailedToLoad!!! $error"),
)),
)),
);
}

@OverRide
void initState() {}
}

I think there is a problem when you click on the screen and use "Navigator.push" etc

IOS:fatal error: 'native_ads/native_ads-Swift.h'

/Documents/programs/SDK/flutter/.pub-cache/hosted/pub.flutter-io.cn/native_ads-0.0.3/ios/Classes/NativeAdsPlugin.m:2:9: fatal error: 'native_ads/native_ads-Swift.h' file not found
#import <native_ads/native_ads-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

incompatibel with google_mobile_ads

we can't user this plugin along side with the new google_mobile_ads Plugin from Flutter Team.
when you use both plugin and try to run the app on device / emulator, the app doesn't start and there is lot of red line in log, saying that many classes are duplicates.
can you please fix this. because the approach of your plugin to implement native ads is the best in my opinion

[ios] Unexpectedly found nil while implicitly unwrapping an Optional value

This error caused to app crash running on both emulator and real ios device with internet connection.
App doesn’t crash without internet. It happens after ad request.

nativeAd object isn’t nil.

What was happened?

Screen Shot 2020-07-02 at 15 32 53

flutter doctor -v
[✓] Flutter (Channel beta, 1.18.0-11.1.pre, on Mac OS X 10.15.4 19E287, locale
    en)
    • Flutter version 1.18.0-11.1.pre at /Users/fusarihan/dev/flutter
    • Framework revision 2738a1148b (7 weeks ago), 2020-05-13 15:24:36 -0700
    • Engine revision ef9215ceb2
    • Dart version 2.9.0 (build 2.9.0-8.2.beta)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/fusarihan/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 47.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.46.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.1

[✓] Connected device (1 available)
    • F • 1d3aa0502670fba6e59b70d4a46bcc67d4fa5c57 • ios • iOS 13.4.1

• No issues found!

Hiding views in Unified Ad if not filled

If using star rating and the ad does not have star rating set, it will remain visible with 0 starts.
These views should be hidden if they are not filled.

Something similar to this:
image

Flutter Web support?

In pub.dev the package shows web compatible but there is no explanation about web implementation, I would like to ask if it is or not.

Thank you.

Ad Refresh

It would be great if we could set an Ad Refresh interval. Currently we only get a new ad when stopping and restarting the application.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.