2012-08-25 10:38:29 +00:00
|
|
|
//
|
|
|
|
// GooglePlusSampleAppDelegate.m
|
|
|
|
//
|
|
|
|
// Copyright 2012 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 "GooglePlusSampleAppDelegate.h"
|
|
|
|
|
|
|
|
#import "GooglePlusSampleMasterViewController.h"
|
2013-01-31 21:22:37 +00:00
|
|
|
#import "GPPDeepLink.h"
|
|
|
|
#import "GPPSignIn.h"
|
|
|
|
#import "GPPSignInButton.h"
|
2012-08-25 10:38:29 +00:00
|
|
|
|
|
|
|
@implementation GooglePlusSampleAppDelegate
|
|
|
|
|
|
|
|
@synthesize window = window_;
|
|
|
|
@synthesize navigationController = navigationController_;
|
|
|
|
@synthesize signInButton = signInButton_;
|
|
|
|
@synthesize auth = auth_;
|
|
|
|
@synthesize share = share_;
|
2013-01-31 21:22:37 +00:00
|
|
|
@synthesize plusMomentsWriteScope = plusMomentsWriteScope_;
|
2012-08-25 10:38:29 +00:00
|
|
|
|
|
|
|
// DO NOT USE THIS CLIENT ID. IT WILL NOT WORK FOR YOUR APP.
|
|
|
|
// Please use the client ID created for you by Google.
|
2013-01-31 21:22:37 +00:00
|
|
|
static NSString * const kClientID =
|
|
|
|
@"122385832599-2mcvobo565un3ab7d6d06m6fjemocto9.apps.googleusercontent.com";
|
2012-08-25 10:38:29 +00:00
|
|
|
|
|
|
|
+ (NSString *)clientID {
|
|
|
|
return kClientID;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark Object life-cycle.
|
|
|
|
|
|
|
|
- (void)dealloc {
|
|
|
|
[window_ release];
|
|
|
|
[navigationController_ release];
|
|
|
|
[signInButton_ release];
|
|
|
|
[auth_ release];
|
|
|
|
[share_ release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)application:(UIApplication *)application
|
|
|
|
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
2013-01-31 21:22:37 +00:00
|
|
|
plusMomentsWriteScope_ = YES;
|
|
|
|
|
2012-08-25 10:38:29 +00:00
|
|
|
self.window = [[[UIWindow alloc]
|
|
|
|
initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
|
|
|
|
GooglePlusSampleMasterViewController *masterViewController =
|
|
|
|
[[[GooglePlusSampleMasterViewController alloc]
|
|
|
|
initWithNibName:@"GooglePlusSampleMasterViewController"
|
|
|
|
bundle:nil] autorelease];
|
|
|
|
self.navigationController =
|
|
|
|
[[[UINavigationController alloc]
|
|
|
|
initWithRootViewController:masterViewController] autorelease];
|
|
|
|
self.window.rootViewController = self.navigationController;
|
|
|
|
[self.window makeKeyAndVisible];
|
2013-01-31 21:22:37 +00:00
|
|
|
|
|
|
|
// Read Google+ deep-link data.
|
|
|
|
GPPDeepLink *deepLink = [GPPDeepLink readDeepLinkAfterInstall];
|
|
|
|
if (deepLink) {
|
|
|
|
UIAlertView *alert = [[[UIAlertView alloc]
|
|
|
|
initWithTitle:@"Read Deep-link Data"
|
|
|
|
message:[deepLink deepLinkID]
|
|
|
|
delegate:nil
|
|
|
|
cancelButtonTitle:@"OK"
|
|
|
|
otherButtonTitles:nil] autorelease];
|
|
|
|
[alert show];
|
|
|
|
}
|
2012-08-25 10:38:29 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)application:(UIApplication *)application
|
|
|
|
openURL:(NSURL *)url
|
|
|
|
sourceApplication:(NSString *)sourceApplication
|
|
|
|
annotation:(id)annotation {
|
|
|
|
// Handle Google+ share dialog URL.
|
|
|
|
if ([share_ handleURL:url
|
|
|
|
sourceApplication:sourceApplication
|
|
|
|
annotation:annotation]) {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle Google+ sign-in button URL.
|
|
|
|
if ([signInButton_ handleURL:url
|
|
|
|
sourceApplication:sourceApplication
|
|
|
|
annotation:annotation]) {
|
|
|
|
return YES;
|
|
|
|
}
|
2013-01-31 21:22:37 +00:00
|
|
|
|
|
|
|
// Handle Google+ deep-link data URL.
|
|
|
|
GPPDeepLink *deepLink = [GPPDeepLink handleURL:url
|
|
|
|
sourceApplication:sourceApplication
|
|
|
|
annotation:annotation];
|
|
|
|
if (deepLink) {
|
|
|
|
UIAlertView *alert = [[[UIAlertView alloc]
|
|
|
|
initWithTitle:@"Handle Deep-link Data"
|
|
|
|
message:[deepLink deepLinkID]
|
|
|
|
delegate:nil
|
|
|
|
cancelButtonTitle:@"OK"
|
|
|
|
otherButtonTitles:nil] autorelease];
|
|
|
|
[alert show];
|
|
|
|
}
|
2012-08-25 10:38:29 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|