Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google+ Sign-In button customization

How to customize Google+ Sign-In button ios ?

is there a way to go directly for sign in with out clicking Google+ Sign-In button ?

like image 498
Rijesh Pv Avatar asked Dec 04 '13 13:12

Rijesh Pv


1 Answers

Yes, there is way to directly sign in Google+.

In AppDelegate, add this,

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation
{
       return [GPPURLHandler handleURL:url
                      sourceApplication:sourceApplication
                             annotation:annotation];   
}

And your login view controller this code parts should be added.

- (void)loginWithGooglePlus
{
    [GPPSignIn sharedInstance].clientID = kClientID;
    [GPPSignIn sharedInstance].scopes= [NSArray arrayWithObjects:kGTLAuthScopePlusLogin, nil];
    [GPPSignIn sharedInstance].shouldFetchGoogleUserID=YES;
    [GPPSignIn sharedInstance].shouldFetchGoogleUserEmail=YES;
    [GPPSignIn sharedInstance].delegate=self;

    [[GPPSignIn sharedInstance] authenticate];
}

- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
                   error:(NSError *)error
{
    if (!error)
    {
        NSLog(@"Google+ login successful");
    }
    else
    {
        NSLog(@"Error: %@", error);
    }
}

kClientID is your app client id taken from google your registered apps. Of course you need to set the delegate ( GPPSignInDelegate ).

like image 134
caglar Avatar answered Nov 03 '22 07:11

caglar