Google Plus, Social
Open Below link
https://console.developers.google.com/apis/library?project=_
Sing In
Project name
LoginUS
I agree that my use of any services and related APIs is subject to my compliance with the applicable Terms of Service.
Select Yes
Click on Creat
Left Side bar click on Credentials tab
OAuth Consent Screen
Select Email address
Enter Product name shown to users
Click on Save
Goto Credentials Click on Creat Credentials
Click on OAuth Client ID
Select iOS
Enter Name
Enter Bundle ID
Click on Creat
Showing Popup OAuth Client Here is your client ID
Click OK
Creat Xcode project
Include the following frameworks in your Xcode project:
- AddressBook.framework
- AssetsLibrary.framework
- Foundation.framework
- CoreLocation.framework
- CoreMotion.framework
- CoreGraphics.framework
- CoreText.framework
- MediaPlayer.framework
- Security.framework
- SystemConfiguration.framework
- UIKit.framework
Drag and Drop
- GooglePlus.framework
- GoogleOpenSource.framework
- GooglePlus.bundle
AppDelegate.m
– (BOOL)application: (UIApplication *)application
openURL: (NSURL *)url
sourceApplication: (NSString *)sourceApplication
annotation: (id)annotation {
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
ViewController.h
#import <GooglePlus/GooglePlus.h>
#import <GoogleOpenSource/GoogleOpenSource.h>
@class GPPSignInButton;
<GPPSignInDelegate>
@property (weak, nonatomic) IBOutlet GPPSignInButton *signInButton;
ViewController.m
#define CLIEND_ID @“98223363200-tteph5459h1qve2js1o3vb4jqeegcghg.apps.googleusercontent.com” //add your Google Plus ClientID here
static NSString * const kClientId = CLIEND_ID;
@synthesize signInButton;
– (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to get the user’s email
// You previously set kClientId in the “Initialize the Google+ client” step
signIn.clientID = kClientId;
[GPPSignIn sharedInstance].actions = [NSArray arrayWithObjects:
@”http://schemas.google.com/AddActivity”,
@”http://schemas.google.com/BuyActivity”,
@”http://schemas.google.com/CheckInActivity”,
@”http://schemas.google.com/CommentActivity”,
@”http://schemas.google.com/CreateActivity”,
@”http://schemas.google.com/ListenActivity”,
@”http://schemas.google.com/ReserveActivity”,
@”http://schemas.google.com/ReviewActivity”,
nil];
// Uncomment one of these two statements for the scope you chose in the previous step
signIn.scopes = @[ kGTLAuthScopePlusLogin ]; // “https://www.googleapis.com/auth/plus.login” scope
//signIn.scopes = @[ @”profile” ]; // “profile” scope
// Optional: declare signIn.actions, see “app activities”
signIn.delegate = self;
[signIn trySilentAuthentication];
}
– (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error
{
NSLog(@”Received error %@ and auth object %@”,error, auth);
if (error) {
// Do some error handling here.
} else {
NSLog(@”%@ %@”,[GPPSignIn sharedInstance].userEmail, [GPPSignIn sharedInstance].userID);
[self refreshInterfaceBasedOnSignIn];
}
}
-(void)refreshInterfaceBasedOnSignIn
{
if ([[GPPSignIn sharedInstance] authentication]) {
// The user is signed in.
self.signInButton.hidden = YES;
// Perform other actions here, such as showing a sign-out button
} else {
self.signInButton.hidden = NO;
// Perform other actions here
}
}
// Share Code
– (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
// This line will fill out the title, description, and thumbnail from
// the URL that you are sharing and includes a link to that URL.
[shareBuilder setURLToShare:[NSURL URLWithString:@”https://www.shinnxstudios.com”]];
[shareBuilder setPrefillText:@”This is an awesome G+ Sample to share”];
// [shareBuilder setTitle:@”Title” description:@”Descp” thumbnailURL:[NSURL URLWithString:@”https://www.fbo.com/imageurl“]];
[shareBuilder open];
}
// For Signout USe this code
– (void)signOut {
[[GPPSignIn sharedInstance] signOut];
}
// Disconnet User
– (void)disconnect {
[[GPPSignIn sharedInstance] disconnect];
}
– (void)didDisconnectWithError:(NSError *)error {
if (error) {
NSLog(@”Received error %@”, error);
} else {
// The user is signed out and disconnected.
// Clean up user data as specified by the Google+ terms.
}
}
Click here to download Google Plus login integretion and google plus share sample Project