Google Plus Login Integration Error iOS

2020-08-24 06:04发布

问题:

Hi i am trying to integrate google+ login on my iOS app. I've followed the instructions form this link.

The examples are working fine but when i tried to implement on my app it is getting this

errorTerminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSBundle gpp_registerFonts]: unrecognized selector sent to class 0x16af620'

I have added the following frameworks Image Any help

Code: in viewdidload of my view

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;
signIn.scopes = [NSArray arrayWithObjects:
                 kGTLAuthScopePlusLogin, // defined in GTLPlusConstants.h
                 nil];
// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;

After that I add this functions

- (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation 
{
    return [GPPURLHandler handleURL:url
        sourceApplication:sourceApplication
                annotation:annotation];
}
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
        error: (NSError *) error
{
    NSLog(@"Received error %@ and auth object %@",error, auth);
}

And i add a button in my view of class GPPSignInButton.

回答1:

Hi the problem is with the -ObjC. Though i ve added the -ObjC earlier but i dnt know why it was not working but when i delete and again add it starts working. Maybe i copy-paste it earlier so there is any space or something.



回答2:

in the app delegate u need to set client id and once u hav set this you dont need to set it again in ViewController

did u added GooglePlus.bundle if not added add it to your project


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {

    [GPPSignIn sharedInstance].clientID = kGoogleplusClientID;
    [GPPDeepLink setDelegate:self];


    ......    
 }


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


next in your myView u can do something like this


 //in .h file
 @class GPPSignInButton;

 @interface ViewController : UIViewController

 @property (retain, nonatomic) IBOutlet GPPSignInButton *signInButton; //sign in button


 .....



//in .m file

- (void)viewDidLoad 
{  
      [GPPSignInButton class]; //for sign in button u need to put a view and set its calss  name as `GPPSignInButton` and connect to IBOutlet of ur signInButton
      [GPPSignIn sharedInstance].shouldFetchGoogleUserEmail = YES;
      [GPPSignIn sharedInstance].shouldFetchGooglePlusUser = YES;


     GPPSignIn *signIn = [GPPSignIn sharedInstance];
     signIn.delegate = self;
   ........ 
           //if u are settings are all correct u will logged in successfully


}




回答3:

I think you are using custom button with IBOutlet connection. Delete outlet connection in Storyboard and try again. It will work.