Skip to content

Commit

Permalink
Publishing latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Emrich committed Aug 6, 2016
1 parent 0ec56ef commit beb5cdd
Show file tree
Hide file tree
Showing 154 changed files with 2,017 additions and 406 deletions.
16 changes: 15 additions & 1 deletion Objective-C/admob/BannerExample/BannerExample/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// Copyright (c) 2014 Google. All rights reserved.
//
// Copyright (C) 2014 Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <UIKit/UIKit.h>

Expand Down
18 changes: 17 additions & 1 deletion Objective-C/admob/BannerExample/BannerExample/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// Copyright (c) 2014 Google. All rights reserved.
//
// Copyright (C) 2014 Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import "AppDelegate.h"

Expand All @@ -15,6 +29,8 @@ - (BOOL)application:(UIApplication *)application

// Use Firebase library to configure APIs
[FIRApp configure];
// Initialize Google Mobile Ads SDK
[GADMobileAds configureWithApplicationID:@"ca-app-pub-3940256099942544~1458002511"];

return YES;
}
Expand Down
16 changes: 15 additions & 1 deletion Objective-C/admob/BannerExample/BannerExample/ViewController.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// Copyright (c) 2014 Google. All rights reserved.
//
// Copyright (C) 2014 Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <UIKit/UIKit.h>

Expand Down
16 changes: 15 additions & 1 deletion Objective-C/admob/BannerExample/BannerExample/ViewController.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// Copyright (c) 2014 Google. All rights reserved.
//
// Copyright (C) 2014 Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

@import GoogleMobileAds;

Expand Down
16 changes: 15 additions & 1 deletion Objective-C/admob/BannerExample/BannerExample/main.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// Copyright (c) 2014 Google. All rights reserved.
//
// Copyright (C) 2014 Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/admob/BannerExample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'

target 'BannerExample' do
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/AdMob'
end
37 changes: 37 additions & 0 deletions Objective-C/admob/BannerExample/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
PODS:
- Firebase/AdMob (3.3.0):
- Firebase/Analytics (= 3.3.0)
- Google-Mobile-Ads-SDK (= 7.8.1)
- Firebase/Analytics (3.3.0):
- FirebaseAnalytics (= 3.2.1)
- Firebase/Core (3.3.0):
- Firebase/Analytics (= 3.3.0)
- FirebaseAnalytics (3.2.1):
- FirebaseInstanceID (~> 1.0)
- GoogleInterchangeUtilities (~> 1.2)
- GoogleSymbolUtilities (~> 1.1)
- GoogleUtilities (~> 1.3)
- FirebaseInstanceID (1.0.7)
- Google-Mobile-Ads-SDK (7.8.1)
- GoogleInterchangeUtilities (1.2.1):
- GoogleSymbolUtilities (~> 1.0)
- GoogleSymbolUtilities (1.1.1)
- GoogleUtilities (1.3.1):
- GoogleSymbolUtilities (~> 1.0)

DEPENDENCIES:
- Firebase/AdMob
- Firebase/Core

SPEC CHECKSUMS:
Firebase: 6250071f0e2440a5c4c67b8cb6b868f868237ac3
FirebaseAnalytics: 0fd6532cb2c3d03cd5cf26ad295ccb091efd3104
FirebaseInstanceID: a9d923f3d0b6fbf9fac89310860357aaadc34be5
Google-Mobile-Ads-SDK: 3c2a6656117989469bfe7645640aa1de024a4c6c
GoogleInterchangeUtilities: def8415a862effc67d549d5b5b0b9c7a2f97d4de
GoogleSymbolUtilities: 33117db1b5f290c6fbf259585e4885b4c84b98d7
GoogleUtilities: 56c5ac05b7aa5dc417a1bb85221a9516e04d7032

PODFILE CHECKSUM: e8d322daf859c9ed2ebe682454f6fdd82d955602

COCOAPODS: 1.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Use Firebase library to configure APIs
[FIRApp configure];
// Initialize Google Mobile Ads SDK
[GADMobileAds configureWithApplicationID:@"ca-app-pub-3940256099942544~1458002511"];

return YES;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ typedef NS_ENUM(NSUInteger, GameState) {
kGameStateEnded = 3 ///< Game has ended.
};

@interface ViewController () <GADInterstitialDelegate, UIAlertViewDelegate>
/// The game length.
static const NSInteger kGameLength = 5;

@interface ViewController () <UIAlertViewDelegate>

/// The interstitial ad.
@property(nonatomic, strong) GADInterstitial *interstitial;

/// The countdown timer.
@property(nonatomic, strong) NSTimer *timer;

/// The game counter.
@property(nonatomic, assign) NSInteger counter;
/// The amount of time left in the game.
@property(nonatomic, assign) NSInteger timeLeft;

/// The state of the game.
@property(nonatomic, assign) GameState gameState;
Expand Down Expand Up @@ -70,18 +73,42 @@ - (void)viewDidLoad {
#pragma mark Game logic

- (void)startNewGame {
[self createAndLoadInterstitial];

self.gameState = kGameStatePlaying;
self.playAgainButton.hidden = YES;
[self createAndLoadInterstitial];
self.counter = 10;
self.gameText.text = [NSString stringWithFormat:@"%ld", (long)self.counter];
self.timeLeft = kGameLength;
[self updateTimeLeft];
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0f
target:self
selector:@selector(decrementCounter:)
selector:@selector(decrementTimeLeft:)
userInfo:nil
repeats:YES];
}

- (void)createAndLoadInterstitial {
self.interstitial =
[[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];

GADRequest *request = [GADRequest request];
// Request test ads on devices you specify. Your test device ID is printed to the console when
// an ad request is made.
request.testDevices = @[ kGADSimulatorID, @"2077ef9a63d2b398840261c8221a0c9a" ];
[self.interstitial loadRequest:request];
}

- (void)updateTimeLeft {
self.gameText.text = [NSString stringWithFormat:@"%ld seconds left!", (long)self.timeLeft];
}

- (void)decrementTimeLeft:(NSTimer *)timer {
self.timeLeft--;
[self updateTimeLeft];
if (self.timeLeft == 0) {
[self endGame];
}
}

- (void)pauseGame {
if (self.gameState != kGameStatePlaying) {
return;
Expand Down Expand Up @@ -109,69 +136,36 @@ - (void)resumeGame {
[self.timer setFireDate:[NSDate dateWithTimeInterval:pauseTime sinceDate:self.previousFireDate]];
}

- (void)decrementCounter:(NSTimer *)timer {
self.counter--;
if (self.counter > 0) {
self.gameText.text = [NSString stringWithFormat:@"%ld", (long)self.counter];
} else {
[self endGame];
}
}

- (void)endGame {
self.gameState = kGameStateEnded;
self.gameText.text = @"Game over!";
self.playAgainButton.hidden = NO;
[self.timer invalidate];
self.timer = nil;
[[[UIAlertView alloc]
initWithTitle:@"Game Over"
message:[NSString stringWithFormat:@"You lasted %ld seconds", (long)kGameLength]
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil] show];
}

#pragma Interstitial button actions

- (IBAction)playAgain:(id)sender {
if (self.interstitial.isReady) {
[self.interstitial presentFromRootViewController:self];
} else {
[[[UIAlertView alloc] initWithTitle:@"Interstitial not ready"
message:@"The interstitial didn't finish loading or failed to load"
delegate:self
cancelButtonTitle:@"Drat"
otherButtonTitles:nil] show];
}
}

- (void)createAndLoadInterstitial {
self.interstitial =
[[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];
self.interstitial.delegate = self;

GADRequest *request = [GADRequest request];
// Request test ads on devices you specify. Your test device ID is printed to the console when
// an ad request is made. GADInterstitial automatically returns test ads when running on a
// simulator.
request.testDevices = @[
@"2077ef9a63d2b398840261c8221a0c9a" // Eric's iPod Touch
];
[self.interstitial loadRequest:request];
[self startNewGame];
}

#pragma mark UIAlertViewDelegate implementation

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
[self startNewGame];
}

#pragma mark GADInterstitialDelegate implementation

- (void)interstitial:(GADInterstitial *)interstitial
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"%s: %@", __PRETTY_FUNCTION__, [error localizedDescription]);
if (self.interstitial.isReady) {
[self.interstitial presentFromRootViewController:self];
} else {
NSLog(@"Ad wasn't ready");
}
self.playAgainButton.hidden = NO;
}

- (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial {
NSLog(@"%s", __PRETTY_FUNCTION__);
[self startNewGame];
}
#pragma mark dealloc

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self
Expand Down
16 changes: 15 additions & 1 deletion Objective-C/admob/InterstitialExample/InterstitialExample/main.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// Copyright (c) 2014 Google. All rights reserved.
//
// Copyright (C) 2014 Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/admob/InterstitialExample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'

target 'InterstitialExample' do
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/AdMob'
end
37 changes: 37 additions & 0 deletions Objective-C/admob/InterstitialExample/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
PODS:
- Firebase/AdMob (3.3.0):
- Firebase/Analytics (= 3.3.0)
- Google-Mobile-Ads-SDK (= 7.8.1)
- Firebase/Analytics (3.3.0):
- FirebaseAnalytics (= 3.2.1)
- Firebase/Core (3.3.0):
- Firebase/Analytics (= 3.3.0)
- FirebaseAnalytics (3.2.1):
- FirebaseInstanceID (~> 1.0)
- GoogleInterchangeUtilities (~> 1.2)
- GoogleSymbolUtilities (~> 1.1)
- GoogleUtilities (~> 1.3)
- FirebaseInstanceID (1.0.7)
- Google-Mobile-Ads-SDK (7.8.1)
- GoogleInterchangeUtilities (1.2.1):
- GoogleSymbolUtilities (~> 1.0)
- GoogleSymbolUtilities (1.1.1)
- GoogleUtilities (1.3.1):
- GoogleSymbolUtilities (~> 1.0)

DEPENDENCIES:
- Firebase/AdMob
- Firebase/Core

SPEC CHECKSUMS:
Firebase: 6250071f0e2440a5c4c67b8cb6b868f868237ac3
FirebaseAnalytics: 0fd6532cb2c3d03cd5cf26ad295ccb091efd3104
FirebaseInstanceID: a9d923f3d0b6fbf9fac89310860357aaadc34be5
Google-Mobile-Ads-SDK: 3c2a6656117989469bfe7645640aa1de024a4c6c
GoogleInterchangeUtilities: def8415a862effc67d549d5b5b0b9c7a2f97d4de
GoogleSymbolUtilities: 33117db1b5f290c6fbf259585e4885b4c84b98d7
GoogleUtilities: 56c5ac05b7aa5dc417a1bb85221a9516e04d7032

PODFILE CHECKSUM: e8d322daf859c9ed2ebe682454f6fdd82d955602

COCOAPODS: 1.0.1
File renamed without changes.
Loading

0 comments on commit beb5cdd

Please sign in to comment.