[英]Google AdMob is not working in Xamarin Form iOS for larger screen devices like iPhone 7 and 7 Plus
我正在使用Xamarin Forms平台開發iOS應用。 我正在使用Google AdMob,並按照以下網址http://motzcod.es/post/154696375922/xamarinforms-google-admob-ads-in-ios實施了該廣告
在iOS版本為10.2的所有設備和模擬器上,它都能正常運行
它也適用於iOS版本10.3,但僅適用於iPhone 5s和5c等較少的設備,不適用於iPhone 6、6s,6s Plus,7、7 Plus的設備和模擬器。
對其進行調試進一步引發以下錯誤,“錯誤Domain = com.google.ads代碼= 13“請求錯誤:收到無效響應。” UserInfo = {NSLocalizedDescription =請求錯誤:收到無效響應。NSLocalizedFailureReason =請求錯誤:收到無效響應。 }”
我搜索了此錯誤並也應用了修復程序,但效果不佳。
如果有人可以幫助,我將不勝感激。 謝謝
您可能想要嘗試App Transport Security ,並將以下行添加到Info.plist
。
<key>NSAppTransportSecurity</key><dict>
<key>NSAllowsArbitraryLoads</key>
<true/></dict>
這樣可以解決您的問題。
僅供參考,我關注了此博客http://motzcod.es/post/154696375922/xamarinforms-google-admob-ads-in-ios
BannerView像這樣在iOS的自定義渲染器中使用
adView = new BannerView(size: AdSizeCons.SmartBannerPortrait,
origin: new CGPoint(0, UIScreen.MainScreen.Bounds.Size.Height - AdSizeCons.Banner.Size.Height))
{
AdUnitID = bannerId,
RootViewController = GetVisibleViewController()
};
無需使用參數化構造函數創建其對象,只需像這樣創建它
adView = new BannerView()
{
AdUnitID = bannerId,
RootViewController = GetVisibleViewController()
};
上述實現解決了所有iOS版本和設備中的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.