Flutter - admob_flutter 1.0.0 #Error: No such module 'AppTrackingTransparency'

20201011

 https://pub.dev/packages/admob_flutter 

Firebase

build.gradle

classpath 'com.google.gms:google-services:4.3.4'


app>src>build.gradle

apply plugin: 'com.google.gms.google-services'
implementation platform('com.google.firebase:firebase-bom:25.12.0')

implementation 'com.google.firebase:firebase-analytics' 

                                                                                                                                                     

Admob-Android

app>src>main>AndroidManifest.xml

<application
android:name="io.flutter.app.FlutterApplication"
android:label="keys"
android:icon="@mipmap/ic_launcher">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-6080925650058329~5412407969"/>

☝<meta-data

android:name..../>

must under the <application>

and out of </activity>

Admob-iOS

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-6080925650058329~8198353404</string>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>

Troubleshoot

#Error: No such module 'AppTrackingTransparency'

1.update to Xcode 12
2.add those two line:
import AppTrackingTransparency
import AdSupport


https://developers.google.com/admob/ios/ios14

well, i  had also added: 

<key>SKAdNetworkItems</key>
 
<array>
   
<dict>
     
<key>SKAdNetworkIdentifier</key>
     
<string>cstr6suwn9.skadnetwork</string>
   
</dict>
 
</array>

                                                                                                                                                     

iOS + Android.dart admob part

static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: <String>['flutterio', 'beautiful apps'],
contentUrl: 'https://flutter.io',
childDirected: false,
testDevices: <String>[], // Android emulators are considered test devices
);

BannerAd myBanner = BannerAd(
adUnitId: Platform.isAndroid
? 'ca-app-pub-6080925650058329/7080712856'
: 'ca-app-pub-6080925650058329/2754455039',
size: AdSize.smartBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("BannerAd event is $event");
},
);

InterstitialAd myInterstitial = InterstitialAd(
adUnitId: Platform.isAndroid
? 'ca-app-pub-6080925650058329/3600115928'
: 'ca-app-pub-6080925650058329/7954810821',
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("InterstitialAd event is $event");
},
);
@override
void initState() {
super.initState();
FirebaseAdMob.instance.initialize(
appId: Platform.isAndroid
? 'ca-app-pub-6080925650058329~5412407969'
: 'ca-app-pub-6080925650058329~8198353404');
myBanner
..load()
..show(
anchorOffset: 60.0,
horizontalCenterOffset: 10.0,
anchorType: AnchorType.bottom,
);
myInterstitial
..load()
..show(
anchorType: AnchorType.bottom,
anchorOffset: 0.0,
horizontalCenterOffset: 0.0,
);
}






Comments

Popular posts from this blog

Go-VSCode -Autocomplete and Auto-import

Go - mail