2
0

Dumped Google+ SDK.

[UPDATED]   Google+ SDK.
This commit is contained in:
Maarten Billemont
2013-04-27 17:14:05 -04:00
parent dc3c30a2f7
commit a6e3b83ebb
206 changed files with 8949 additions and 1417 deletions

View File

@@ -4,26 +4,45 @@
//
// Copyright 2012 Google Inc.
//
// Usage of this SDK is subject to the Google+ Platform Terms of Service:
// Use of this SDK is subject to the Google+ Platform Terms of Service:
// https://developers.google.com/+/terms
//
#import <Foundation/Foundation.h>
@class GPPDeepLink;
// A protocol optionally implemented by the client of |GPPDeepLink|.
@protocol GPPDeepLinkDelegate
// Notifies the client that a deep link has been received either from
// |readDeepLinkAfterInstall| or |handleURL:sourceApplication:annotation:|.
- (void)didReceiveDeepLink:(GPPDeepLink *)deepLink;
@end
// This class handles a deep link within a share posted on Google+.
// For more information on deep links, see
// http://developers.google.com/+/mobile/ios/share .
@interface GPPDeepLink : NSObject
// Sets the delegate to handle the deep link.
+ (void)setDelegate:(id<GPPDeepLinkDelegate>)delegate;
// 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.
// deep-link ID within your app. The delegate will be called if set and if a
// deep link is found.
+ (GPPDeepLink *)readDeepLinkAfterInstall;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns
// |GooglePlusDeepLink| if |GooglePlusDeepLink| handled this URL, |nil|
// otherwise.
// otherwise. The delegate will be called if set and if a deep link is found.
// Also see |handleURL:sourceApplication:annotation:| in |GPPURLHandler|.
+ (GPPDeepLink *)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
@@ -31,9 +50,10 @@
// 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/.
// This instance method indicates where the user came from before arriving in
// your app. This method is provided for you to collect engagement metrics.
// For the possible values, see
// http://developers.google.com/+/mobile/ios/source-values .
- (NSString *)source;
@end

View File

@@ -4,39 +4,41 @@
//
// Copyright 2012 Google Inc.
//
// Usage of this SDK is subject to the Google+ Platform Terms of Service:
// Use of this SDK is subject to the Google+ Platform Terms of Service:
// https://developers.google.com/+/terms
//
// To allow a user to share with Google+, please follow these steps:
//
// 0. Create a project on Google APIs console,
// 0. Create a project on Google API console,
// https://code.google.com/apis/console . Under "API Access", create a
// client ID as "Installed application" with the type "iOS", and
// register the bundle ID of your application.
// register the bundle ID of your app.
//
// 1. Initialize a GPPShare instance with your registered client ID:
// 1. Initialize the |GPPSignIn| instance with your registered client ID,
// and get the |GPPShare| instance.
//
// GPPShare *gppShare = [[GPPShare alloc] initWithClientID:myClientID];
// [[GPPSignIn shareInstance] setClientID:myClientID];
// GPPShare *gppShare = [GPPShare sharedInstance];
//
// 2. In the code where the share dialog is to be opened:
// 2. In the code where the share dialog will be opened,
//
// [[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
// you want to set text to prefill user comment in the share dialog, e.g.
// you can optionally call any of the |GPPShareBuilder| methods before
// calling |open|, for example, if there is a particular URL resource to be
// shared, or if you want to set text to prefill user comment in the share
// dialog, such as:
//
// NSURL *urlToShare = [NSURL URLWithString:@"http://www.google.com/"];
// NSString *prefillText = @"You probably already know this site...";
// [[[[gppShare shareDialog] setURLToShare:urlToShare]
// setPrefillText:prefillText] open];
//
// 3. In the 'YourApp-info.plist' settings for your application, add a URL
// type to be handled by your application. Make the URL scheme the same as
// the bundle ID of your application.
// 3. In the '<YourApp>-info.plist' settings for your app, add a URL type to be
// handled by your app. Make the URL scheme the same as your app bundle ID.
//
// 4. In your application delegate, implement
// 4. In your application delegate, implement:
// - (BOOL)application:(NSString*)application
// openURL:(NSURL *)url
// sourceApplication:(NSString*)sourceApplication
@@ -50,7 +52,7 @@
// }
//
// 5. Optionally, if you want to be notified of the result of the share action,
// have a delegate class implement |GPPShareDelegate|, e.g.
// have a delegate class implement |GPPShareDelegate|, for example:
//
// @interface MyDelegateClass : NSObject<GPPShareDelegate>;
//
@@ -63,28 +65,32 @@
#import <Foundation/Foundation.h>
// Protocol to receive the result of the share action.
@class GPPSignIn;
// The protocol to receive the result of the share action.
@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.
// successfully shared her post, |NO| otherwise, such as if the user canceled
// the post.
- (void)finishedSharing:(BOOL)shared;
@end
// The builder protocol to open the share dialog.
// For more information on sharing, see
// http://developers.google.com/+/mobile/ios/share .
@protocol GPPShareBuilder<NSCopying>
// Sets the URL resource to be shared.
- (id<GPPShareBuilder>)setURLToShare:(NSURL *)urlToShare;
// Sets the text to prefill user comment in the share dialog.
// Sets the text to prefill user's comment in the share dialog.
- (id<GPPShareBuilder>)setPrefillText:(NSString *)prefillText;
// 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.
// deep link and don't have a URL resource. |title| is required.
- (id<GPPShareBuilder>)setTitle:(NSString *)title
description:(NSString *)description
thumbnailURL:(NSURL *)thumbnailURL;
@@ -92,24 +98,46 @@
// 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.
// which can be up to 512 characters in length.
- (id<GPPShareBuilder>)setContentDeepLinkID:(NSString *)contentDeepLinkID;
// Sets the call-to-action button of the shared content preview.
// The call-to-action button consists of a label, URL, and deep-link ID.
// The |label| is a string key defined under "data-calltoactionlabel" on
// http://developers.google.com/+/web/share/interactive#button_attr_calltoactionlabel
// that maps to the actual button text.
// You must set either the |url| or |deepLinkID|, or both.
// The |url| is where the user is taken to after tapping on the button.
// The |deepLinkID| is the call-to-action deep-link ID that takes the user
// straight to a specific action in your app. It can either be a fully qualified
// URI, or URI path, which can be up to 512 characters in length.
// Note: In order to set the call-to-action button:
// 1. User must have been authenticated with scopes including
// "https://www.googleapis.com/auth/plus.login".
// 2. Either |setURLToShare:| or |setTitle:description:thumbnailURL:| must also
// be called.
- (id<GPPShareBuilder>)setCallToActionButtonWithLabel:(NSString *)label
URL:(NSURL *)url
deepLinkID:(NSString *)deepLinkID;
// 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+.
// For more information on sharing, see
// http://developers.google.com/+/mobile/ios/share .
@interface GPPShare : NSObject
// The object to be notified when the share action has finished.
@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/
// with their corresponding bundle ID before they can be used.
- (id)initWithClientID:(NSString *)clientID;
// Returns a shared |GPPShare| instance.
// |[GPPSignIn sharedInstance].clientID| must be initialized with a client ID
// registered in the Google API console, https://code.google.com/apis/console/
// with the app's bundle ID.
+ (GPPShare *)sharedInstance;
// Returns a share dialog builder instance. Call its |open| method to
// create the dialog after setting the parameters as needed.
@@ -118,6 +146,7 @@
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GPPShare| handled this URL.
// Also see |handleURL:sourceApplication:annotation:| in |GPPURLHandler|.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;

View File

@@ -4,7 +4,7 @@
//
// Copyright 2012 Google Inc.
//
// Usage of this SDK is subject to the Google+ Platform Terms of Service:
// Use of this SDK is subject to the Google+ Platform Terms of Service:
// https://developers.google.com/+/terms
//
@@ -13,54 +13,127 @@
@class GTMOAuth2Authentication;
@class GTMOAuth2ViewControllerTouch;
// 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|.
// A protocol implemented by the client of |GPPSignIn| to receive a refresh
// token or an error.
@protocol GPPSignInDelegate
// Authorization has finished and is successful if |error| is |nil|.
// The authorization has finished and is successful if |error| is |nil|.
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error;
// Finished disconnecting user from the app.
// The operation was successful if |error| is |nil|.
@optional
- (void)didDisconnectWithError:(NSError *)error;
@end
// |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 GPPSignIn:
// 1) GPPSignIn *signIn =
// [[GPPSignIn alloc] initForClientID:clientID
// language:@"en"
// scope:@"https://www.googleapis.com/auth/plus.me"
// keychainName:nil];
// [signIn setDelegate:self];
// 2) Setup delegate methods |finishedWithAuth|, etc.
// 3) Call |handleURL| from |application:openUrl:...| in your app delegate.
// 4) [auth authenticate:YES];
// This class signs the user in with Google. It provides single sign-on
// via the Google+ app (if installed), Chrome for iOS (if installed), or Mobile
// Safari.
//
// For reference, please see "Google+ Sign-In for iOS" at
// https://developers.google.com/+/mobile/ios/sign-in .
// Here is sample code to use |GPPSignIn|:
// 1) Get a reference to the |GPPSignIn| shared instance:
// GPPSignIn *signIn = [GPPSignIn sharedInstance];
// 2) Set the OAuth 2.0 scopes you want to request:
// [signIn setScopes:[NSArray arrayWithObject:
// @"https://www.googleapis.com/auth/plus.login"]];
// 2) Call [signIn setDelegate:self];
// 3) Set up delegate method |finishedWithAuth:error:|.
// 4) Call |handleURL| on the shared instance from |application:openUrl:...|
// in your app delegate.
// 5) Call [signIn authenticate];
@interface GPPSignIn : NSObject
// The authentication object for the current user, or |nil| if there is
// currently no logged in user.
@property (nonatomic, readonly) GTMOAuth2Authentication *authentication;
// The Google user ID. It is only available if |shouldFetchGoogleUserID| is set
// and either |trySilentAuthentication| or |authenticate| has been completed
// successfully.
@property (nonatomic, readonly) NSString *userID;
// The Google user's email. It is only available if |shouldFetchGoogleUserEmail|
// is set and either |trySilentAuthentication| or |authenticate| has been
// completed successfully.
@property (nonatomic, readonly) NSString *userEmail;
// The object to be notified when authentication is finished.
@property (nonatomic, assign) id<GPPSignInDelegate> delegate;
// All properties below are optional parameters. If they need to be set, set
// before calling |authenticate|.
// The client ID of the app from the Google APIs console.
// Must set for sign-in to work.
@property (nonatomic, copy) NSString *clientID;
// The API scopes requested by the app in an array of |NSString|s.
// The default value is |@[@"https://www.googleapis.com/auth/plus.login"]|.
@property (nonatomic, copy) NSArray *scopes;
// Whether or not to attempt Single-Sign-On when signing in.
// If |attemptSSO| is true, the sign-in button tries to authenticate with the
// Google+ application if it is installed. If false, it always uses Google+ via
// Chrome for iOS, if installed, or Mobile Safari for authentication.
// The default value is |YES|.
@property (nonatomic, assign) BOOL attemptSSO;
// The language for sign-in, in the form of ISO 639-1 language code
// optionally followed by a dash and ISO 3166-1 alpha-2 region code,
// such as |@"it"| or |@"pt-PT"|.
// Only set if different from system default.
@property (nonatomic, copy) NSString *language;
// Name of the keychain to save the sign-in state.
// Only set if a custom name needs to be used.
@property (nonatomic, copy) NSString *keychainName;
// An |NSString| array of moment types used by your app. Use values from the
// full list at
// https://developers.google.com/+/api/moment-types .
// such as "http://schemas.google.com/AddActivity".
// This property is required only for writing moments, with
// "https://www.googleapis.com/auth/plus.login" as a scope.
@property (nonatomic, copy) NSArray *actions;
// Whether or not to fetch user email after signing in. The email is saved in
// the |GTMOAuth2Authentication| object.
// the |GTMOAuth2Authentication| object. Note that using this flag automatically
// adds "https://www.googleapis.com/auth/userinfo.email" scope to the request.
@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
// name.
- (id)initWithClientID:(NSString *)clientID
language:(NSString *)language
scope:(NSArray *)scope
keychainName:(NSString *)keychainName;
// Whether or not to fetch user ID after signing in. The ID can be retrieved
// by |googleUserID| after user has been authenticated.
// Note, a scope, such as "https://www.googleapis.com/auth/plus.login" or
// "https://www.googleapis.com/auth/plus.me", that provides user ID must be
// included in |scopes| for this flag to work.
@property (nonatomic, assign) BOOL shouldFetchGoogleUserID;
// Returns a shared |GPPSignIn| instance.
+ (GPPSignIn *)sharedInstance;
// Checks whether the user has either currently signed in or has previous
// authentication saved in keychain.
- (BOOL)hasAuthInKeychain;
// Attempts to authenticate silently without user interaction.
// Returns |YES| and calls the delegate if the user has either currently signed
// in or has previous authentication saved in keychain.
- (BOOL)trySilentAuthentication;
// Starts the authentication process. Set |attemptSSO| to try single sign-on.
// Set |clearKeychain| to remove previously stored authentication in the
// keychain.
- (void)authenticate:(BOOL)attemptSSO clearKeychain:(BOOL)clearKeychain;
// If |attemptSSO| is true, try to authenticate with the Google+ app, if
// installed. If false, always use Google+ via Chrome or Mobile Safari for
// authentication. The delegate will be called at the end of this process.
- (void)authenticate;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GPPSignIn| handled this URL.
// Also see |handleURL:sourceApplication:annotation:| in |GPPURLHandler|.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
@@ -68,4 +141,10 @@
// Removes the OAuth 2.0 token from the keychain.
- (void)signOut;
// Disconnects the user from the app and revokes previous authentication.
// If the operation succeeds, the OAuth 2.0 token is also removed from keychain.
// The token is needed to disconnect so do not call |signOut| if |disconnect| is
// to be called.
- (void)disconnect;
@end

View File

@@ -4,53 +4,41 @@
//
// Copyright 2012 Google Inc.
//
// Usage of this SDK is subject to the Google+ Platform Terms of Service:
// Use of this SDK is subject to the Google+ Platform Terms of Service:
// https://developers.google.com/+/terms
//
#import <UIKit/UIKit.h>
@class GPPSignIn;
@protocol GPPSignInDelegate;
// The various visual styles supported by the GPPSignInButton.
// The various layout styles supported by the GPPSignInButton.
// The minmum size of the button depends on the language used for text.
// The following dimensions (in points) fit for all languages:
// kGPPSignInButtonStyleStandard: 226 x 48
// kGPPSignInButtonStyleWide: 308 x 48
// kGPPSignInButtonStyleIconOnly: 46 x 48 (no text, fixed size)
typedef enum {
kGPPSignInButtonStyleNormal,
kGPPSignInButtonStyleWide
kGPPSignInButtonStyleStandard = 0,
kGPPSignInButtonStyleWide = 1,
kGPPSignInButtonStyleIconOnly = 2
} 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 GPPSignInButton : UIView
// The various color schemes supported by the GPPSignInButton.
typedef enum {
kGPPSignInButtonColorSchemeDark = 0,
kGPPSignInButtonColorSchemeLight = 1
} GPPSignInButtonColorScheme;
// The OAuth 2.0 client ID of the application.
@property(nonatomic, copy) NSString *clientID;
// This class provides the Google+ sign-in button. You can instantiate this
// class programmatically or from a NIB file. You should set up the
// |GPPSignIn| shared instance with your client ID and any additional scopes,
// implement the delegate methods for |GPPSignIn|, and add this button to your
// view hierarchy.
@interface GPPSignInButton : UIButton
// 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) 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.
// Sets the sign-in button layout style. The default style is standard.
- (void)setStyle:(GPPSignInButtonStyle)style;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GPPSignInButton| handled this URL.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
// Sets the sign-in button color scheme. The default scheme is dark.
- (void)setColorScheme:(GPPSignInButtonColorScheme)colorScheme;
@end

View File

@@ -0,0 +1,25 @@
//
// GPPURLHandler.h
// Google+ iOS SDK
//
// Copyright 2013 Google Inc.
//
// Use of this SDK is subject to the Google+ Platform Terms of Service:
// https://developers.google.com/+/terms
//
#import <Foundation/Foundation.h>
@interface GPPURLHandler : NSObject
// Calls |handleURL:sourceApplication:annotation:| for
// |[GPPSignIn sharedInstance]|, |[GPPShare sharedInstance]|, and
// |GPPDeepLink|, and returns |YES| if any of them handles the URL.
// This method can be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation| instead of calling
// those methods individually.
+ (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
@end

Binary file not shown.