Skip to content
This repository was archived by the owner on Mar 12, 2022. It is now read-only.

Initialize

Bruno D'Luka edited this page Jan 2, 2021 · 21 revisions

Initialize

Before creating any native ads, you must initalize the admob. It can be initialized only once:

import 'package:flutter/foundation.dart';

String get admobUnitId {
  /// Always test with test ads
  if (kDebugMode)
    return 'ca-app-pub-3940256099942544/2247696110';
  else return 'your-native-ad-unit-id';
}

void main() {
  // Add this line if you will initialize it before runApp
  WidgetsFlutterBinding.ensureInitialized();
  // default native ad unit id: ca-app-pub-3940256099942544/2247696110
  NativeAds.initialize(admobUnitId);
  runApp(MyApp());
}

❗NOTE:❗ Unit IDs are NOT App IDs

Clone this wiki locally