Google+ Sign-In button customization

google-plus, ios, iphone

Solution

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` ).

Problem

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 ?

Original source

Related problems