1
votes

I am trying to integrate Admob and also Firebase into a Xcode (8.2.1) project that was exported from Unity (5.6b).

My podfile

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

platform :ios, ‘9.0’

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

All ok frameworks are added.

Ive included my GoogleService-Info.plist

In my UnityAppController i have

#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-******"];

and in my viewController i have

@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

my .plist includes

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

I receive the following errors

2016-10-27 14:11:37.651 com[2322:1744977] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9814)

2016-10-27 14:11:37.730 com[2322] [Firebase/Core][I-NET901017] Encounter network error. Code, error: -999, Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://play.googleapis.com/log, NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSLocalizedDescription=cancelled}

2016-10-27 14:11:37.759 com[2322:1745037] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9814)

2016-10-27 14:11:37.783 com[2322] [Firebase/Analytics][I-ACS901017] Encounter network error. Code, error: -999, Error Domain=NSURLErrorDomain Code=-999 "cancelled" 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=cancelled}

2016-10-27 14:11:37.788 com[2322] [Firebase/Core][I-COR000020] Error posting to Clearcut: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://play.googleapis.com/log, NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSLocalizedDescription=cancelled}

Plssssssssss Help Me

Thank You.

Kristan Halls

Immacul8 Apps

1
Did this ever get answered? I'm having the same problem and desperate for a solution. I've been everywhere, nothing seems to have worked yet.Treyten Carey

1 Answers

0
votes

NSURLConnection is not recommended any more.

You can update your plugin, if that still does not work.

You can change to https://github.com/unity-plugins/Firebase-Admob-Unity

Important Tips of the plugin

If you not config AndroidManifest.xml, APP will crash

Attach admob to Object on scene, init admob before call admob fun

Add GoogleService-Info.plist to your xcode project, otherwise, APP will crash

Add Link Flag -ObjC to your xcode project,otherwise,APP will crash

Unzip GoogleMobileAds.framework.zip to GoogleMobileAds.framework

Edit res/values/string.xml and set the appid to your

When export unity project with this plugin ,http and https are configed auto