Xcode Error When Added AdMob Plugin To Ionic Proje

2020-06-05 01:02发布

I have an Ionic 3 Project and its running normally on Ionic DevApp And Xcode. But When i added AdMob Plugin , its running normally Ionic DevApp but its not running on Xcode. I tried Simulator and Real Device but i have some mistake both of them.

There is my error codes;

Terminating app due to uncaught exception
'GADInvalidInitializationException', reason: 
'The Google Mobile Ads SDK was initialized incorrectly. 
Google AdMob publishers should follow instructions here: 

https://googlemobileadssdk.page.link/admob-ios-update-plist 
to include the AppMeasurement framework, 
set the -ObjC linker flag, and set 
GADApplicationIdentifier with a valid App ID. 

Google Ad Manager publishers should follow 
instructions here: 
https://googlemobileadssdk.page.link/ad-manager-ios-update-plist

3条回答
Lonely孤独者°
2楼-- · 2020-06-05 01:41

For Ionic App with Admob plugin (I've tried just in Ioniv V3) you can add this in ./config.xml under platform ios to auto populate app-name-info.plist file at every build time.

<platform name="ios">
   <config-file parent="GADApplicationIdentifier" target="*-Info.plist">
      <string>ca-app-pub-12345/12345</string>
   </config-file>

   <config-file parent="GADIsAdManagerApp" target="*-Info.plist">
      <true />
   </config-file>

   ... (other lines) ...

</platform>

Run cordova prepare to regenerated the file (additionally delete ios platform and reinstall it using: ionic cordova platform rm ios , ionic cordova platform add ios).

查看更多
对你真心纯属浪费
3楼-- · 2020-06-05 01:49

Have had this problem for two days now. The problem seems that the xcode project's plist file is not getting the admob settings right. So had to add them manually like this:

Open the your-app-name-Info.plist file under "ionic-project-root/platforms/ios/your-app-name/" and add these lines:

<key>GADIsAdManagerApp</key>
<true/>
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXXXX~YYYYYYY</string>

Being ca-app-pub-XXXXXXX~YYYYYYY your ios app ID in admob. Now the error should go away.

查看更多
爷的心禁止访问
4楼-- · 2020-06-05 01:57

enter image description here

There is a new procedure, you need to add GADIsAdManagerApp key for info.plist file with boolean YES value

查看更多
登录 后发表回答