{"id":15486988,"url":"https://github.com/sakebook/flutter_native_ads","last_synced_at":"2025-04-22T15:25:33.618Z","repository":{"id":56835201,"uuid":"204664491","full_name":"sakebook/flutter_native_ads","owner":"sakebook","description":"Show AdMob Native Ads use PlatformView","archived":false,"fork":false,"pushed_at":"2020-09-07T11:10:54.000Z","size":10925,"stargazers_count":66,"open_issues_count":19,"forks_count":32,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-17T04:19:09.284Z","etag":null,"topics":["admob","android","flutter","flutter-plugin","ios","native-ads","platform-view"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/native_ads","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sakebook.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-27T09:09:48.000Z","updated_at":"2024-03-01T07:00:11.000Z","dependencies_parsed_at":"2022-09-02T03:51:18.531Z","dependency_job_id":null,"html_url":"https://github.com/sakebook/flutter_native_ads","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakebook%2Fflutter_native_ads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakebook%2Fflutter_native_ads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakebook%2Fflutter_native_ads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakebook%2Fflutter_native_ads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sakebook","download_url":"https://codeload.github.com/sakebook/flutter_native_ads/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250265998,"owners_count":21402211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admob","android","flutter","flutter-plugin","ios","native-ads","platform-view"],"created_at":"2024-10-02T06:20:42.505Z","updated_at":"2025-04-22T15:25:33.591Z","avatar_url":"https://github.com/sakebook.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flutter_native_ads\n[![version](https://img.shields.io/pub/v/native_ads.svg?style=flat-square)](https://pub.dartlang.org/packages/native_ads)\n\nFlutter plugin for AdMob Native Ads. Compatible with Android and iOS using PlatformView.\n\n|Android|iOS|\n|:---:|:---:|\n|![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/android_capture.png)|![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/ios_capture.png)|\n\n## Getting Started\n### Android\n- [AndroidManifest changes](https://developers.google.com/admob/android/quick-start#update_your_androidmanifestxml)\n\nAdMob 17 requires the App ID to be included in the `AndroidManifest.xml`. Failure\nto do so will result in a crash on launch of your app.  The line should look like:\n\n```xml\n\u003cmeta-data\n    android:name=\"com.google.android.gms.ads.APPLICATION_ID\"\n    android:value=\"[ADMOB_APP_ID]\"/\u003e\n```\n\nwhere `[ADMOB_APP_ID]` is your App ID.  You must pass the same value when you \ninitialize the plugin in your Dart code.\n\n### iOS\n- [Info.plist changes](https://developers.google.com/admob/ios/quick-start#update_your_infoplist)\n\nAdmob 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:\n\n```xml\n\u003ckey\u003eGADApplicationIdentifier\u003c/key\u003e\n\u003cstring\u003e[ADMOB_APP_ID]\u003c/string\u003e\n```\n\nwhere `[ADMOB_APP_ID]` is your App ID.  You must pass the same value when you initialize the plugin in your Dart code.\n\nAnd PlatformView\n\n```xml\n\u003ckey\u003eio.flutter.embedded_views_preview\u003c/key\u003e\n\u003ctrue/\u003e\n```\n\n## Layout\nThis plugin supported custom layout. You need to create a layout file.\n\n### Android\nYou can use anything if the parent is a ViewGroup.\nThe example uses ConstraintLayout.\n\nUse [`com.google.android.gms.ads.formats.UnifiedNativeAdView`](https://developers.google.com/android/reference/com/google/android/gms/ads/formats/UnifiedNativeAdView) for the parent.\n\n![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/android_unified_native_ad_view.png)\n\nUse [`com.google.android.gms.ads.formats.MediaView`](https://developers.google.com/android/reference/com/google/android/gms/ads/formats/MediaView) for MediaView.\n\n![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/android_media_view.png)\n\n- xml\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003ccom.google.android.gms.ads.formats.UnifiedNativeAdView \n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:id=\"@+id/flutter_native_ad_unified_native_ad\"\n    ...\n    \n    \u003c!-- ViewGroup --\u003e\n    \u003candroidx.constraintlayout.widget.ConstraintLayout\n        android:id=\"@+id/relativeLayout\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\u003e\n        \n        ...\n\n        \u003ccom.google.android.gms.ads.formats.MediaView\n            android:id=\"@+id/flutter_native_ad_media\"\n            ...\n```\n\n[example](https://github.com/sakebook/flutter_native_ads/blob/master/example/android/app/src/main/res/layout/native_ad_layout.xml)\n\n### iOS\nPlease set [GADUnifiedNativeAdView](https://developers.google.com/admob/ios/api/reference/Classes/GADUnifiedNativeAdView) for the parent.\n\n![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/ios_unified_native_ad_view.png)\n\nPlease set [GADMediaView](https://developers.google.com/admob/ios/api/reference/Classes/GADMediaView) to MediaView.\n\n![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/ios_media_view.png)\n\nPlease set Restoration ID for View that displays attribution\n\n![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/ios_attribution.png)\n\n[example](https://github.com/sakebook/flutter_native_ads/blob/master/example/ios/Runner/UnifiedNativeAdView.xib)\n\n## Mapping Native Ads to Layout\nNeed to mapping the view\n\n### Android\nMapping by view id\n\n|View|ID|\n|:---:|:---:|\n|UnifiedNativeAdView|flutter_native_ad_unified_native_ad|\n|Headline|flutter_native_ad_headline|\n|Body|flutter_native_ad_body|\n|Call To Action|flutter_native_ad_call_to_action|\n|Attribution|flutter_native_ad_attribution|\n|MediaView|flutter_native_ad_media|\n|Icon|flutter_naitve_ad_icon|\n|Star rating|flutter_naitve_ad_star|\n|Store|flutter_naitve_ad_store|\n|Price|flutter_naitve_ad_price|\n|Advertiser|flutter_naitve_ad_advertiser|\n\n### iOS\nMapping by Outlet\n\n![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/ios_mapping.png)\n\n## Usage\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:native_ads/native_ad_param.dart';\nimport 'package:native_ads/native_ad_view.dart';\n\nimport 'package:native_ads/native_ads.dart';\n\nvoid main() {\n  WidgetsFlutterBinding.ensureInitialized();\n  NativeAds.initialize();\n  runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        appBar: AppBar(\n          title: const Text('NativeAds example app'),\n        ),\n        body: Center(\n          child: ListView.separated(\n            itemBuilder: (context, index) {\n              if (index % 10 == 0) {\n                return Padding(\n                  padding: const EdgeInsets.all(8.0),\n                  child: SizedBox(\n                    width: double.infinity,\n                    height: 320,\n                    child: NativeAdView(\n                      onParentViewCreated: (_) {\n                      },\n                      androidParam: AndroidParam()\n                        ..placementId = \"ca-app-pub-3940256099942544/2247696110\" // test\n                        ..packageName = \"{{YOUR_ANDROID_APP_PACKAGE_NAME}}\"\n                        ..layoutName = \"{{YOUR_CREATED_LAYOUT_FILE_NAME}}\"\n                        ..attributionText = \"AD\"\n                        ..testDevices = [\"{{YOUR_TEST_DEVICE_IDS}}\"],\n                      iosParam: IOSParam()\n                        ..placementId = \"ca-app-pub-3940256099942544/3986624511\" // test\n                        ..bundleId = \"{{YOUR_IOS_APP_BUNDLE_ID}}\"\n                        ..layoutName = \"{{YOUR_CREATED_LAYOUT_FILE_NAME}}\"\n                        ..attributionText = \"SPONSORED\"\n                        ..testDevices = [\"{{YOUR_TEST_DEVICE_IDS}}\"],\n                      onAdImpression: () =\u003e print(\"onAdImpression!!!\"),\n                      onAdClicked: () =\u003e print(\"onAdClicked!!!\"),\n                      onAdFailedToLoad: (Map\u003cString, dynamic\u003e error) =\u003e print(\"onAdFailedToLoad!!! $error\"),\n                    ),\n                  ),\n                );\n              } else {\n                return Padding(\n                  padding: const EdgeInsets.all(8.0),\n                  child: Text(\n                    \"this is text $index\",\n                    style: Theme.of(context).textTheme.body1,\n                  ),\n                );\n              }\n            },\n            itemCount: 50,\n            separatorBuilder: (context, _) =\u003e const Divider(),\n          ),\n        ),\n      ),\n    );\n  }\n}\n```\n\n## Supported native ads fields\n- Headline(Required)\n- Body(Required)\n- Call To Action(Required)\n- Ad Attribution(Required)\n- Media\n- Icon\n- Star rating\n- Store\n- Price\n- Advertiser\n\n## Event callback\nReceive callbacks for some events by passing to the NativeAdView constructor\n\n- onAdImpression\n- onAdClicked\n- onAdFailedToLoad\n- onAdLeftApplication\n- onAdLoaded\n\n## Reference\n- Mobile Ads SDK Release Notes\n  - [Android](https://developers.google.com/admob/android/rel-notes)\n  - [iOS](https://developers.google.com/admob/ios/rel-notes)\n\n## Limitations\n\nThis is just an initial version of the plugin. There are still some\nlimitations:\n\n- No support [Mediation Ads](https://developers.google.com/admob/android/mediate).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakebook%2Fflutter_native_ads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsakebook%2Fflutter_native_ads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakebook%2Fflutter_native_ads/lists"}