Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Admob AppID use Android or iOS?

Silly question I'm sure, but when you make an AdMob app in the admob console, you have a choice of Android or iOS apps. That means 2 different IDs.

Which one should we use in Flutter admob plugin?

FirebaseAdMob.instance.initialize(appId: appId);
like image 589
Gabeloooooo Avatar asked Aug 25 '18 21:08

Gabeloooooo


1 Answers

How about setting as follows?

import 'dart:io';

  FirebaseAdMob.instance.initialize(
    appId: Platform.isAndroid
        ? 'ca-app-pub-NNNNNNNNNNNNNNNN~NNNNNNNNNN'
        : 'ca-app-pub-MMMMMMMMMMMMMMMM~MMMMMMMMMM',
  );

If you dislike conditional operators you can set as follows.

import 'dart:io';

  var appId;
  if (Platform.isAndroid) {
    appId = 'ca-app-pub-NNNNNNNNNNNNNNNN~NNNNNNNNNN';
  } else {
    appId = 'ca-app-pub-MMMMMMMMMMMMMMMM~MMMMMMMMMM';
  }
  FirebaseAdMob.instance.initialize(appId: appId);
like image 141
Ganessa Avatar answered Oct 12 '22 11:10

Ganessa