我有一个Ionic 3项目,它在Ionic DevApp和Xcode上正常运行。但是,当我添加AdMob插件时,它可以正常运行Ionic DevApp,但不能在Xcode上运行。我尝试了Simulator和Real Device,但是我两个都犯了一些错误。
有我的错误代码;
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
答案 0 :(得分:4)
这个问题现在已经两天了。问题似乎是xcode项目的plist文件没有正确设置admob设置。因此必须像这样手动添加它们:
打开“ ionic-project-root / platforms / ios / your-app-name /”下的your-app-name-Info.plist文件,并添加以下行:
<key>GADIsAdManagerApp</key>
<true/>
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-XXXXXXX~YYYYYYY</string>
在admob中成为ca-app-pub-XXXXXXX〜YYYYYYY您的ios应用ID。现在错误应该消失了。
答案 1 :(得分:1)
对于具有Admob插件的离子应用程序(我已经在Ioniv V3中进行过尝试),您可以在平台ios下的 ./ config.xml 中添加它以自动填充应用程序-name-info.plist文件在每个构建时间。
<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>
运行cordova prepare
以重新生成文件(另外删除ios平台,然后使用ionic cordova platform rm ios
,ionic cordova platform add ios
重新安装)。
答案 2 :(得分:0)