2
0

Sharing on Facebook, Twitter and Google+

[FIXED]     Font of navbar.
[FIXED]     A few compile fixes.
[IMPROVED]  Made properties nonatomic.
[ADDED]     Support for facebook, twitter and google+ sharing.
This commit is contained in:
Maarten Billemont
2012-08-25 12:38:29 +02:00
parent b9ccee398e
commit 5e7b6ed60e
131 changed files with 24758 additions and 26 deletions

View File

@@ -0,0 +1,112 @@
//
// GooglePlusShare.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
//
// To allow a user to share with Google+, please follow these steps:
//
// 0. Create a project on Google APIs 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.
//
// 1. Initialize a GooglePlusShare instance with your registered client ID:
//
// GooglePlusShare *googlePlusShare =
// [[GooglePlusShare alloc] initWithClientID:myClientID];
//
// 2. In the code where the share dialog is to be opened:
//
// [[googlePlusShare 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.
//
// NSURL *urlToShare = [NSURL URLWithString:@"http://www.google.com/"];
// NSString *prefillText = @"You probably already know this site...";
// [[[[googlePlusShare 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.
//
// 4. In your application delegate, implement
// - (BOOL)application:(NSString*)application
// openURL:(NSURL *)url
// sourceApplication:(NSString*)sourceApplication
// annotation:(id)annotation {
// if ([googlePlusShare 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.
//
// @interface MyDelegateClass : NSObject<GooglePlusShareDelegate>;
//
// - (void)finishedSharing:(BOOL)shared {
// // The share action was successful if |shared| is YES.
// }
//
// MyDelegateClass *myDelegate = [[MyDelegateClass alloc] init];
// googlePlusShare.delegate = myDelegate;
#import <Foundation/Foundation.h>
// Protocol to receive the result of the share action.
@protocol GooglePlusShareDelegate
// 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.
- (void)finishedSharing:(BOOL)shared;
@end
// The builder protocol to open the share dialog.
@protocol GooglePlusShareBuilder<NSCopying>
// Sets the URL resource to be shared.
- (id<GooglePlusShareBuilder>)setURLToShare:(NSURL *)urlToShare;
// Sets the text to prefill user comment in the share dialog.
- (id<GooglePlusShareBuilder>)setPrefillText:(NSString *)prefillText;
// Opens the share dialog.
- (void)open;
@end
// The primary class for the share action on Google+.
@interface GooglePlusShare : NSObject
// The object to be notified when the share action has finished.
@property (nonatomic, assign) id<GooglePlusShareDelegate> 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 share dialog builder instance. Call its |open| method to
// create the dialog after setting the parameters as needed.
- (id<GooglePlusShareBuilder>)shareDialog;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GooglePlusShare| handled this URL.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
@end

View File

@@ -0,0 +1,67 @@
//
// GooglePlusSignIn.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>
@class GTMOAuth2Authentication;
@class GTMOAuth2ViewControllerTouch;
// Protocol implemented by the client of GooglePlusSignIn 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
// Authorization has finished and is successful if |error| is |nil|.
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error;
@end
// |GooglePlusSignIn| 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
// 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];
@interface GooglePlusSignIn : NSObject
// The object to be notified when authentication is finished.
@property (nonatomic, assign) id<GooglePlusSignInDelegate> delegate;
// 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;
// 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;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GooglePlusSignIn| handled this URL.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
// Removes the OAuth 2.0 token from the keychain.
- (void)signOut;
@end

View File

@@ -0,0 +1,52 @@
//
// GooglePlusSignInButton.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 <UIKit/UIKit.h>
@class GooglePlusSignIn;
@protocol GooglePlusSignInDelegate;
// The various visual styles supported by the GooglePlusSignInButton.
typedef enum {
kGooglePlusSignInButtonStyleNormal,
kGooglePlusSignInButtonStyleWide
} GooglePlusSignInButtonStyle;
// 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
// 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;
// Actually does the work of signing in with Google+.
@property(nonatomic, readonly) GooglePlusSignIn *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;
// Sets the sign-in button. The default style is normal.
- (void)setStyle:(GooglePlusSignInButtonStyle)style;
// This method should be called from your |UIApplicationDelegate|'s
// |application:openURL:sourceApplication:annotation|. Returns |YES| if
// |GooglePlusSignInButton| handled this URL.
- (BOOL)handleURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
@end

Binary file not shown.

Binary file not shown.