2
0

Update Google+ integration.

[UPDATED]   Google+ SDK to 1.1.0.
This commit is contained in:
Maarten Billemont
2013-01-31 16:22:37 -05:00
parent cc015ada1b
commit 6c23134e47
74 changed files with 3383 additions and 2012 deletions

View File

@@ -0,0 +1,39 @@
//
// GPPDeepLink.h
// Google+ iOS SDK
//
// Copyright 2012 Google Inc.
//
// Usage of this SDK is subject to the Google+ Platform Terms of Service:
// https://developers.google.com/+/terms
//
#import <Foundation/Foundation.h>
@interface GPPDeepLink : NSObject
// Returns a |GPPDeepLink| for your app to handle, or |nil| if not found. The
// deep-link ID can be obtained from |GPPDeepLink|. It is stored when a user
// clicks a link to your app from a Google+ post, but hasn't yet installed your
// app. The user will be redirected to the App Store to install your app. This
// method should be called on or near your app launch to take the user to
// deep-link ID within your app.
+ (GPPDeepLink *)readDeepLinkAfterInstall;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns
// |GooglePlusDeepLink| if |GooglePlusDeepLink| handled this URL, |nil|
// otherwise.
+ (GPPDeepLink *)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
// The deep-link ID in |GPPDeepLink| that was passed to the app.
- (NSString *)deepLinkID;
// This indicates where the user came from before arriving in your app. This is
// provided for you to collect engagement metrics. For the possible values,
// see our developer docs at http://developers.google.com/+/mobile/ios/.
- (NSString *)source;
@end

View File

@@ -1,5 +1,5 @@
//
// GooglePlusShare.h
// GPPShare.h
// Google+ iOS SDK
//
// Copyright 2012 Google Inc.
@@ -15,14 +15,13 @@
// client ID as "Installed application" with the type "iOS", and
// register the bundle ID of your application.
//
// 1. Initialize a GooglePlusShare instance with your registered client ID:
// 1. Initialize a GPPShare instance with your registered client ID:
//
// GooglePlusShare *googlePlusShare =
// [[GooglePlusShare alloc] initWithClientID:myClientID];
// GPPShare *gppShare = [[GPPShare alloc] initWithClientID:myClientID];
//
// 2. In the code where the share dialog is to be opened:
//
// [[googlePlusShare shareDialog] open];
// [[gppShare shareDialog] open];
//
// You may optionally call |setURLToShare:| and/or |setPrefillText:| before
// calling |open|, if there is a particular URL resource to be shared, or
@@ -30,7 +29,7 @@
//
// NSURL *urlToShare = [NSURL URLWithString:@"http://www.google.com/"];
// NSString *prefillText = @"You probably already know this site...";
// [[[[googlePlusShare shareDialog] setURLToShare:urlToShare]
// [[[[gppShare shareDialog] setURLToShare:urlToShare]
// setPrefillText:prefillText] open];
//
// 3. In the 'YourApp-info.plist' settings for your application, add a URL
@@ -42,30 +41,30 @@
// openURL:(NSURL *)url
// sourceApplication:(NSString*)sourceApplication
// annotation:(id)annotation {
// if ([googlePlusShare handleURL:url
// sourceApplication:sourceApplication
// annotation:annotation]) {
// if ([gppShare handleURL:url
// sourceApplication:sourceApplication
// annotation:annotation]) {
// return YES;
// }
// // Other handling code here...
// }
//
// 5. Optionally, if you want to be notified of the result of the share action,
// have a delegate class implement |GooglePlusShareDelegate|, e.g.
// have a delegate class implement |GPPShareDelegate|, e.g.
//
// @interface MyDelegateClass : NSObject<GooglePlusShareDelegate>;
// @interface MyDelegateClass : NSObject<GPPShareDelegate>;
//
// - (void)finishedSharing:(BOOL)shared {
// // The share action was successful if |shared| is YES.
// }
//
// MyDelegateClass *myDelegate = [[MyDelegateClass alloc] init];
// googlePlusShare.delegate = myDelegate;
// gppShare.delegate = myDelegate;
#import <Foundation/Foundation.h>
// Protocol to receive the result of the share action.
@protocol GooglePlusShareDelegate
@protocol GPPShareDelegate
// Reports the status of the share action, |shared| is |YES| if user has
// successfully shared her post, |NO| otherwise, e.g. user canceled the post.
@@ -74,24 +73,38 @@
@end
// The builder protocol to open the share dialog.
@protocol GooglePlusShareBuilder<NSCopying>
@protocol GPPShareBuilder<NSCopying>
// Sets the URL resource to be shared.
- (id<GooglePlusShareBuilder>)setURLToShare:(NSURL *)urlToShare;
- (id<GPPShareBuilder>)setURLToShare:(NSURL *)urlToShare;
// Sets the text to prefill user comment in the share dialog.
- (id<GooglePlusShareBuilder>)setPrefillText:(NSString *)prefillText;
- (id<GPPShareBuilder>)setPrefillText:(NSString *)prefillText;
// Opens the share dialog.
- (void)open;
// Sets the title, description, and thumbnail URL of the shared content preview
// in the share dialog. Only set these fields if you are sharing with a content
// deep link and don't have a URL resource. Title and description are required
// fields.
- (id<GPPShareBuilder>)setTitle:(NSString *)title
description:(NSString *)description
thumbnailURL:(NSURL *)thumbnailURL;
// Sets the content deep-link ID that takes the user straight to your shared
// content. Only set this field if you want the content deep-linking feature.
// The content deep-link ID can either be a fully qualified URI, or URI path,
// which can be up to 64 characters in length.
- (id<GPPShareBuilder>)setContentDeepLinkID:(NSString *)contentDeepLinkID;
// Opens the share dialog. Returns |NO| if there was an error, |YES| otherwise.
- (BOOL)open;
@end
// The primary class for the share action on Google+.
@interface GooglePlusShare : NSObject
@interface GPPShare : NSObject
// The object to be notified when the share action has finished.
@property (nonatomic, assign) id<GooglePlusShareDelegate> delegate;
@property (nonatomic, assign) id<GPPShareDelegate> delegate;
// All Google+ objects must be initialized with a client ID registered
// in the Google APIs console, https://code.google.com/apis/console/
@@ -100,11 +113,11 @@
// Returns a share dialog builder instance. Call its |open| method to
// create the dialog after setting the parameters as needed.
- (id<GooglePlusShareBuilder>)shareDialog;
- (id<GPPShareBuilder>)shareDialog;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GooglePlusShare| handled this URL.
// |GPPShare| handled this URL.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;

View File

@@ -1,5 +1,5 @@
//
// GooglePlusSignIn.h
// GPPSignIn.h
// Google+ iOS SDK
//
// Copyright 2012 Google Inc.
@@ -13,10 +13,10 @@
@class GTMOAuth2Authentication;
@class GTMOAuth2ViewControllerTouch;
// Protocol implemented by the client of GooglePlusSignIn to receive a refresh
// Protocol implemented by the client of GPPSignIn to receive a refresh
// token or an error. It is up to the client to present the OAuth 2.0 view
// controller if single sign-on is disabled via |attemptSSO| in |authenticate|.
@protocol GooglePlusSignInDelegate
@protocol GPPSignInDelegate
// Authorization has finished and is successful if |error| is |nil|.
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
@@ -24,11 +24,11 @@
@end
// |GooglePlusSignIn| signs the user in with Google+. It provides single sign-on
// |GPPSignIn| signs the user in with Google+. It provides single sign-on
// via the Google+ app, if installed, or Mobile Safari.
// Here is sample code to use GooglePlusSignIn:
// 1) GooglePlusSignIn *signIn =
// [[GooglePlusSignIn alloc] initForClientID:clientID
// Here is sample code to use GPPSignIn:
// 1) GPPSignIn *signIn =
// [[GPPSignIn alloc] initForClientID:clientID
// language:@"en"
// scope:@"https://www.googleapis.com/auth/plus.me"
// keychainName:nil];
@@ -36,10 +36,14 @@
// 2) Setup delegate methods |finishedWithAuth|, etc.
// 3) Call |handleURL| from |application:openUrl:...| in your app delegate.
// 4) [auth authenticate:YES];
@interface GooglePlusSignIn : NSObject
@interface GPPSignIn : NSObject
// The object to be notified when authentication is finished.
@property (nonatomic, assign) id<GooglePlusSignInDelegate> delegate;
@property (nonatomic, assign) id<GPPSignInDelegate> delegate;
// Whether or not to fetch user email after signing in. The email is saved in
// the |GTMOAuth2Authentication| object.
@property (nonatomic, assign) BOOL shouldFetchGoogleUserEmail;
// Initializes with your |clientID| from the Google APIs console. Set |scope| to
// an array of your API scopes. Set |keychainName| to |nil| to use the default
@@ -56,7 +60,7 @@
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GooglePlusSignIn| handled this URL.
// |GPPSignIn| handled this URL.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;

View File

@@ -1,5 +1,5 @@
//
// GooglePlusSignInButton.h
// GPPSignInButton.h
// Google+ iOS SDK
//
// Copyright 2012 Google Inc.
@@ -10,41 +10,45 @@
#import <UIKit/UIKit.h>
@class GooglePlusSignIn;
@protocol GooglePlusSignInDelegate;
@class GPPSignIn;
@protocol GPPSignInDelegate;
// The various visual styles supported by the GooglePlusSignInButton.
// The various visual styles supported by the GPPSignInButton.
typedef enum {
kGooglePlusSignInButtonStyleNormal,
kGooglePlusSignInButtonStyleWide
} GooglePlusSignInButtonStyle;
kGPPSignInButtonStyleNormal,
kGPPSignInButtonStyleWide
} GPPSignInButtonStyle;
// A view that displays the Google+ sign-in button. You can instantiate this
// class programmatically or from a NIB file. Once instantiated, you should
// set the client ID and delegate properties and add this view to your own view
// hierarchy.
@interface GooglePlusSignInButton : UIView
@interface GPPSignInButton : UIView
// The OAuth 2.0 client ID of the application.
@property(nonatomic, copy) NSString *clientID;
// See GooglePlusSignIn.h for details on this delegate.
@property(nonatomic, assign) id<GooglePlusSignInDelegate> delegate;
// See GPPSignIn.h for details on this delegate.
@property(nonatomic, assign) id<GPPSignInDelegate> delegate;
// Actually does the work of signing in with Google+.
@property(nonatomic, readonly) GooglePlusSignIn *googlePlusSignIn;
@property(nonatomic, readonly) GPPSignIn *googlePlusSignIn;
// The OAuth 2.0 scopes for the APIs that you are using. This is used to fetch
// an OAuth 2.0 token. By default, this is set to the
// https://www.googleapis.com/auth/plus.me scope.
@property(nonatomic, copy) NSArray *scope;
// Whether or not to fetch user email after signing in. The email is saved in
// the |GTMOAuth2Authentication| object.
@property (nonatomic, assign) BOOL shouldFetchGoogleUserEmail;
// Sets the sign-in button. The default style is normal.
- (void)setStyle:(GooglePlusSignInButtonStyle)style;
- (void)setStyle:(GPPSignInButtonStyle)style;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GooglePlusSignInButton| handled this URL.
// |GPPSignInButton| handled this URL.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;

Binary file not shown.