How to integrate Facebook / Google + without redirecting Safari browser in iOS app

I tried to integrate Facebook / Google + into my application. I can do this thanks to the built-in Facebook platform, the Google Plus platform, the open-source Google platform, in the iOS application, having received information from the account added in the application settings application. I can also do this by opening the Safari browser and redirecting it to the application after logging in to Facebook and Goolge +. so I don’t need to redirect the Safari browser.

+5
source share
4 answers

Using the new Google+ SDK, the user does not need to re-enter the password in safari or in any browser. Take a look at this: https://developers.google.com/+/mobile/ios/sign-in

If the user has their own Google or Google+ mobile application installed, the user does not need to re-enter their Google credentials to authorize your application.

OR

Try it with GTMOAuth2ViewControllerTouch

 - (id)initWithScope:(NSString *)scope clientID:(NSString *)clientID clientSecret:(NSString *)clientSecret keychainItemName:(NSString *)keychainItemName completionHandler:(GTMOAuth2ViewControllerCompletionHandler)handler 

Many links are available on the Internet. Google Drive iOS SDK: Cancel Login Button

+2
source

Do not use Google-Plus, use GoogleSignIn. Google posted this solution:

Comment No. 109 on question 900 from fa ... @ google.com: iOS SDK SignIn does not leave the application [Apple appstore rejection] https://code.google.com/p/google-plus-platform/issues/detail?id = 900

Hello to all,

I am pleased to announce this. Today we launched version 2.0 of Google Login, with full built-in support for Login via WebView. We hope this update will finally fix the issue of the App Store crash due to the use of our SDK.

Full documentation is here: https://developers.google.com/identity/sign-in/ios

Weve wrote a migration guide from G + Sign in here: https://developers.google.com/identity/sign-in/ios/quick-migration-guide

+1
source

You can use the code below to access Google+ using Webview:

Initialize UIWebview:

 NSString *url = [NSString stringWithFormat:@"https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=%@&redirect_uri=%@&scope=%@",client_id,callbakc,scope]; UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; [webView setDelegate:self]; [self.view addSubview:webView]; [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]; 

Implementation of delegate methods:

 - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType { // [indicator startAnimating]; if ([[[request URL] host] isEqualToString:@"localhost"]) { // Extract oauth_verifier from URL query NSString* verifier = nil; NSArray* urlParams = [[[request URL] query] componentsSeparatedByString:@"&"]; for (NSString* param in urlParams) { NSArray* keyValue = [param componentsSeparatedByString:@"="]; NSString* key = [keyValue objectAtIndex:0]; if ([key isEqualToString:@"code"]) { verifier = [keyValue objectAtIndex:1]; break; } } if (verifier) { NSString *authToken = [NSString stringWithFormat:@"code=%@&client_id=%@&client_secret=%@&redirect_uri=%@&grant_type=authorization_code", verifier,client_id,secret,callbakc]; //Use Token to Login } else { // ERROR! } [webView removeFromSuperview]; webView = nil; return NO; } return YES; 

}

0
source

Use Scocial.framework https://developer.apple.com/library/ios/documentation/Social/Reference/Social_Framework/

 __block ACAccount * facebookAccount; ACAccountStore *accountStore = [[ACAccountStore alloc] init]; NSDictionary *emailReadPermisson = @{ ACFacebookAppIdKey : @"YOUR_API_KEY", ACFacebookPermissionsKey : @[@"email"], ACFacebookAudienceKey : ACFacebookAudienceEveryone, }; NSDictionary *publishWritePermisson = @{ ACFacebookAppIdKey : @"YOUR_API_KEY", ACFacebookPermissionsKey : @[@"publish_actions"], ACFacebookAudienceKey : ACFacebookAudienceEveryone }; ACAccountType *facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; //Request for Read permission [accountStore requestAccessToAccountsWithType:facebookAccountType options:emailReadPermisson completion:^(BOOL granted, NSError *error) {if(granted){ // Enter your code}]; 
0
source

All Articles