Xcode Error When Added AdMob Plugin To Ionic Project

若如初见. 提交于 2020-02-19 06:47:11

问题


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

回答1:


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.




回答2:


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




回答3:


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).



来源:https://stackoverflow.com/questions/55577811/xcode-error-when-added-admob-plugin-to-ionic-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!