Use Google-Signin to log into App but stay signed out on Safari - ios

I have integrated Google-Signin into an iOS Application and it works well as far as signing in or signing up is concerned.
The only problem is that, I dont want the user to be logged into Google on iOS Safari after I have used Google-Signin.
I have verified that, before I log into my app, I am signed out of google in iOS Safari. Then I go to my app and I use Google-Signin to log into my app, once that is done I then go back to iOS Safari and refresh the google page and all of a sudden it shows me signed in with the same account that I used to log in to the app.
How do i just use Google-Signin to simply log into the app and stay logged out of iOS safari?

I've researched the topic and it seems the only way to perform logout is to use SFSafariViewController to open provider's logout page
For Google this is https://accounts.google.com/logout
This way requires some additional UX changes, because this action will open Safari window for a second and user should not be confused.

Try to use GIDSignIn it will open safariviewcontroller inside the app.

You can change which content from your Google Account syncs with the Apple apps on your device. You can also remove your Google Account from your Apple apps at any time, which stops syncing.
To change what syncs or remove your Google Account:
On your iPhone or iPad, open the Settings app.
Select Mail, Contacts, Calendars or Safari
Choose the account you'd like to edit or remove.
Make the changes you want.
To change what content syncs: Next to the content you want to sync, turn on the switch. Turn it off for content you don't want to sync.
To remove your account: Select Delete Account.

Related

How to do facebook login without opening a browser at all?

The IOS app I'm currently working on uses FBSDKLoginManager().logInWithReadPermissions, which opens a browser in the app for user to login to facebook. Then, the browser closes, and the app uses the FBSDKLoginManagerLoginResult to proceed.
However, I want to change it so that the app uses preset settings to log into facebook in the background, without actually opening a browser at all. To put it in a simpler way, the app should not open the browser, but still cause a regular log-in. Is that possible?
Just to clarify, this feature is only intended when the app is running in the developer mode, not for the users.
Thank you!
EDIT: I also found FBSDKLoginBehaviorSystemAccount, which
Attempts log in through the Facebook account currently signed in through
the device Settings.
However, I have no idea about how to implement this in swift, and I cannot find any resource online besides the brief description in FacebookSDK's documentation. It will be great if someone can help!

Facebook iOS SDK - open session and request read permissions

I'm using
(void)openWithBehavior:(FBSessionLoginBehavior)behavior completionHandler:(FBSessionStateHandler)handler
to open my session, which works fine. After open, I then get my read permissions with:
(void)requestNewReadPermissions:(NSArray*)readPermissions completionHandler:(FBSessionRequestPermissionResultHandler)handler
This works fine, but for users signing in through Mobile Safari (or likely the Facebook iOS app, haven't tested), users get jumped back and forth twice (tap login in my app, jump to Mobile Safari, log in there, jump back to my app, jump back to Mobile Safari, approve permissions, jump back to my app.
Returning users - those who have signed out of my app (and token removed), also get a double-jump - each time Mobile Safari tells the user they've already approved the app.
I'm using openWithBehavior because I prioritize the native iOS login using FBSessionLoginBehaviorUseSystemAccountIfPresent. I don't see a version of this combined with an initial permissions request (such as openActiveSessionWithReadPermissions...).
I was hoping that, for subsequent logins, permissions would already be known via session.permissions but in testing that value is null until requestNewReadPermissions is called.
Is it possible to remove the double-jump from either or both scenarios (first user login, subsequent user login) yet still achieve the same permissions?
You can "init" your session with read permissions by calling the initWithPermissions: method. Then call openWithBehavior:completionHandler: which will do only 1 open call with the permissions you've already set.

iOS Facebook switches back to app between login & permissions

I'm trying to setup my app to publish a simple post to a user's Facebook feed (image url, link, description). They don't need to use Facebook for anything else so the first time they click "Share" it needs to authorize the app, and the publish permissions.
If they have their credentials stored in the device as of iOS 6 they simply get two alert boxes and it's done with. But if they don't, or have an older version, it switches out to Safari for login. My problem is that it is then switching the user back to my app, then immediately back again to Safari to accept the publish permission. It's very jarring and unprofessional.
What I would like is for the page in Safari to change after the login to the permissions page so they can accept it, and THEN switch back to my app. I know this can be done because the popular Mixology app does exactly this behavior. Unfortunately Facebook keeps changing their SDK and all the information I find online is outdated.
I wrote up a solution here: FacebookSDK presents login UI twice to avoid the double switch.
Basically, you can use openActiveSessionWithPublishPermissions: to do what you want. However, you have to handle the special case where the user has signed in to Facebook from the device settings, which requires requests for read and publish permissions into two separate calls.

Facebook App Requests aren't shown on iOS devices?

I've sent an app invitation from an iPad app to a test Facebook account via Facebook's API. When I login to the test account on my PC, the app request is there.
When I login to the test account on my iPad (either via Safari or via the Facebook App), I can see the number "1" next to the App Centre tab, but when I click it and go to the App Centre, there's no request. In fact, I can't see any App Centre areas dedicated to requests on Facebook for iOS - there's only Social Picks and Top Apps. Any explanation for this?
This is caused by an incorrect configuration on the Facebook app setting page. When you are setting up the app, you need to make sure the following is set correctly.
Go to developers.facebook.com then select "Apps". Edit your app and fill in the following..
iOS App Bundle (dont think it's essential but fill it in, this the bundle id from Xcode (com.companyname.appname))
iPhone/iPad App Store ID - This is ESSENTIAL, one of these must be filled in with a valid app store ID. You get this when you create an app with iTunes Connect. If you create an app, and fill in the details right up to the point where it asks you to submit the binary, it will generate what Apple refers to as an Apple ID (or iTunes Id?). It's just a long integer value. It doesn't have to be for the corresponding app, if you already have apps in the app store just log in to iTunes connect and use an existing one for testing.
Configured for iOS SSO - Enabled
Configured for Deep Linking - Enabled
The only functionality you get from Facebook when a user clicks an app notification on iOS is the user being redirected to the app, if installed, or to the App Store if not. Also if you want your app notifications to show up on desktop, you'll need a Canvas URL under the "App On Facebook" section.
In my tests I had to have a canvas URL to get iOS notifications working, but I'm not sure if this is a bug with Facebook or intended behaviour, so if it doesn't work with just iOS enabled, enable app on Facebook too and stick in a random url if you don't have one.
I just figured there can be another reason for this symptom: if your app has location restriction (only available in certain countries), the user who receives the request has to be in that country (e.g. I had to connect with mine via GeoEdge).

How to prevent auto-launching of our iOS app from links in FB iOS app?

We have an iOS app that publishes certain activity to Facebook that contains links to pages on our domain. Our intention is for friends to click on those links and view them as webpages.
However, when you click on links in these published stories in the FB iOS app, it's auto launching our app instead of going to an embedded Web View or kicking out to safari.
Note: We still want to have single sign on (SSO), so just want to change the behavior of clicking links in published stories.
To clarify, this is what I'm talking about:
My app is able to publishes http://foo.com/123 into the FB newsfeed for a particular user that opts in.
That person's friends see the link, but when they click it, it just goes to http://foo.com/123 in the browser instead of launching my FOO app. This is because my app doesn't yet handle incoming context from FB iOS app.
I still want FB SSO to work from my FOO app. That is, when clicking on FB sign in in my FOO app, it jumps out to the FB iOS app (if installed) and does a single sign on and redirects back to my app. IOW, I don't want to break this authentication scenario that currently works.
What setting in the FB developers App Settings controls this? It's not clear from the documentation. I see sections for Native iOS app and Website which I currently have set but it's unclear which sub-setting affects the behavior in question. Also, it's not clear even if I was to find the setting, can I affect it without affecting SSO.
The setting you want in the Facebook App dialog is under the iOS Native section (see the screenshot below) - set both the highlighted sections to Disabled.
This won't affect Facebook login/SSO in the app, so you'll still be able to do the OAuth dances.

Resources