iOS 10.2 Firebase / Admob集成 - NSURLSession / NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9814)

时间:2017-03-04 08:18:25

标签: ios unity3d

我正在尝试将Admob和Firebase集成到从Unity(5.6b)导出的Xcode(8.2.1)项目中。

我的podfile

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, ‘9.0’

target ‘my_app do
  pod 'Firebase/Core'
  pod 'Firebase/AdMob'
end

添加所有ok框架。

我已加入我的GoogleService-Info.plist

在我的UnityAppController中我有

#import "FirebaseCore/FirebaseCore.h"//;
#import "FirebaseAnalytics/FirebaseAnalytics.h"//;
#import "Firebase/Firebase.h"//;
#import "GoogleMobileAds/GoogleMobileAds.h"//;

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    ::printf("-> applicationDidFinishLaunching()\n");

    [FIRApp configure];

    [GADMobileAds configureWithApplicationID:@"ca-app-pub-******"];

在我的viewController中我有

@implementation UnityPortraitOnlyViewController

- (NSUInteger)supportedInterfaceOrientations
{
    return 1 << UIInterfaceOrientationPortrait;
}

- (void)viewWillAppear:(BOOL)animated
{
    [GetAppController() updateAppOrientation:UIInterfaceOrientationPortrait];

    [super viewWillAppear:animated];

    GADBannerView *adView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

    adView.rootViewController = self;

    adView.adUnitID = @"ca-app-pub-********/4839119450";

    GADRequest *request = [GADRequest request];

    request.testDevices = @[ kGADSimulatorID ];

    request.testDevices = @[ @"e4022a2432e3186717781c4cf08318d0" ];



///   // Place the ad view onto the screen.

    [self.view addSubview:adView];

///   // Request an ad without any additional targeting information.

    [adView loadRequest:request];

// [adView loadRequest:[GADRequest request]];

}

- (void)adViewDidReceiveAd:(GADBannerView *)adView {
    [self.view addSubview:adView];

    adView.hidden = NO;

    NSLog( @"Google ad shown");
}

@end

我的.plist包括

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsForMedia</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>googleapis.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

我收到以下错误

  

2016-10-27 14:11:37.651 com [2322:1744977] NSURLSession / NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9814)

     

2016-10-27 14:11:37.730 com [2322] [Firebase / Core] [I-NET901017]遇到网络错误。代码,错误:-999,错误域= NSURLErrorDomain代码= -999“已取消”UserInfo = {NSErrorFailingURLKey = https://play.googleapis.com/log,NSErrorFailingURLStringKey = https://play.googleapis.com/log,NSLocalizedDescription =已取消}

     

2016-10-27 14:11:37.759 com [2322:1745037] NSURLSession / NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9814)

     

2016-10-27 14:11:37.783 com [2322] [Firebase / Analytics] [I-ACS901017]遇到网络错误。代码,错误:-999,错误域= NSURLErrorDomain代码= -999“已取消”UserInfo = {NSErrorFailingURLKey = https://app-measurement.com/config/app/1:871662309991:ios:7c633c48a9e59939?app_instance_id=13CD3CF5B68F44768F9AB618E4069B46&platform=ios&gmp_version=3700,NSErrorFailingURLStringKey = https://app-measurement.com/config/app/1:871662309991:ios:7c633c48a9e59939?app_instance_id=13CD3CF5B68F44768F9AB618E4069B46&platform=ios&gmp_version=3700,NSLocalizedDescription =已取消}

     

2016-10-27 14:11:37.788 com [2322] [Firebase / Core] [I-COR000020]错误发布到Clearcut:错误域= NSURLErrorDomain代码= -999“已取消”UserInfo = {NSErrorFailingURLKey = {{ 3}},NSErrorFailingURLStringKey = https://play.googleapis.com/log,NSLocalizedDescription = cancel}

Plssssssssss帮帮我

谢谢。

Kristan Halls

Immacul8 Apps

1 个答案:

答案 0 :(得分:0)

不再建议使用NSURLConnection。

如果仍然无法工作,则可以更新插件。

您可以更改为https://github.com/unity-plugins/Firebase-Admob-Unity

该插件的重要提示

如果您未配置AndroidManifest.xml,则APP将崩溃

将admob附加到场景中的对象,在调用admob fun之前将其初始化为adp

将GoogleService-Info.plist添加到您的xcode项目中,否则,APP将崩溃

将链接标志-ObjC添加到您的xcode项目中,否则,APP将崩溃

将GoogleMobileAds.framework.zip解压缩到GoogleMobileAds.framework

编辑res / values / string.xml并将appid设置为您的

使用此插件导出统一项目时,会自动配置http和https