Login to Facebook Without Leaving App - ios

I am using the Facebook SDK and I use the standart way of logging in a user (I use a FBSDKLoginButton). The problem is that when the user clicks on the view my app goes to the background and safari opens.
My app got rejected from the appstore because of this.
How can I make the login happen inside my app?

Related

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

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.

How to handle URLs from Facebook Open Graph actions in iOS app

I'm building an iOS app that has Facebook open graph actions, and when I post an action on Facebook, on mobile app, I'm getting a link to my mobile app's ID on the App Store, which is not available yet. As a placeholder (otherwise Facebook doesn't save my settings), I've put an ID of another app that I have. Whenever I tap an Open Graph story on Facebook from my new app in Facebook iOS app, An App Store page of my previous app opens. I need the functionality to handle open graph action taps from Facebook iOS app before I submit my app to App Store. How can I test URL handling functionality in a such scenario?
Here is how my Facebook Native iOS App dashboard looks like:
Bundle ID matches my app's ID in my app exactly. iPhone/iPad App Store ID links to one of my previous apps, else Facebook doesn't accept my settings when I click Save button, complaining about app not yet being available on App Store. Facebook login and deep linking are both enabled, and URL schemes are registered the same way (the one starting with fb continues with my Facebook app ID) in the app bundle too. But still, my app doesn't launch when I tap a story on Facebook mobile app. Instead, a popup to install the app with the ID that I've specified launches (though, weird enough, I have that app installed too).
Facebook documents this here: https://developers.facebook.com/docs/ios/link-to-your-native-app-ios-sdk/
Just look under How to handle deep links to provide a more relevant user experience

FBWebDIalogs generates 'An error has occured' when trying to post a feed in iOS

I'd already implemented an App both on FB and iOS that published updates to the users timeline using the Feed Dialog. This was working as intended up until a few months ago, when most users started seeing the 'An Error has Occurred. Please try again later' page.
I set out to update the FB SDK to the latest version and hopefully fix this issue. Initially I have had success posting stories with the basic tutorial app, but once I removed the native IOS FB login settings, the error screen re-appeared.
Steps to reproduce:
Start with a fresh iOS simulator.
Log in to Facebook via the setting screen.
Run the basic tutorial, with FBWebDialogs presentFeedDialogModallyWithSession:parameters:handler: added as a share button.
Login works as expected.
Share works as expected and presents the web dialog allowing me to post to my timeline.
Quit the App (not just switch out of it)
From Settings, delete the Facebook account.
Re-run the App and tap login -- you will be presented with the web login dialog.
Login and 'share' to make the call to FBWebDialogs.
Note the 'error has occurred' screen.
Dismiss this and tap the logout button.
Tap login, and once again, you will be presented with the web login dialog.
Login and notice you are asked to confirm the FBApps access (you'll be told it's already been authorized). Tap OK.
Tap Share and you will now see the 'Feed' dialog as expected.
(You can logout or not at this step, it makes no difference). Go back to the iOS settings page and re-add your Facebook account.
Run the App, and tap log in.
You will be presented with the web UI login screen (this is not expected).
After logging in, tap share to initiate a FBWebDialog call.
Note the 'error has occured' screen. At this point, it is impossible to post except by deleting the Facebook account in iOS settings and going back to step 8.
The problem seems to occur if the user ever deletes their FB settings from the device. Also, if the user has had FB settings on their device via the iOS settings screen and then tries to log in via the web ui, the feed dialog post will fail.
I'd like to know how to solve this problem.

How to tell an iphone app user what will happen before opening Facebook login dialogue

Apps that allow users to log in over a 3rd party authentication provider (e.g. Facebook, Google, Twoitter,...) should open a browser window to let the user authenticate against the provider. That means, at some point, an app is backgrounded and the user interacts with a browser window. Just before the browser opens, it's a recommended pratctice to inform the user about what will happen (see e.g. Getting Started with OAuth 2.0 - O'Reilly), let's say an alert window with something like "you will leave now the XYZ app and a browser window will open where you can enter your credentials safely".
My question: How can that be done if I use the facebook SDK for ios? Looking at the SDK, there seem to be no notifications and no designated states that would allow me to detect that the sdk is about to background my app and about to opening either Safari or the Facebook app.
Use a simple alert that explains what will happen when pressing the button (or however you choose to do it). And when the user has pressed the OK on the alert sign them in.
However I'm quite certain that in Facebook terms of service you have to have some sort of Facebook trademark before interacting with facebook and it seems like standard practice to mention facebook in some way on a button and then log-in the user without mentioning it, since it plays on the user expectation.
Especially when using iOS 6.0 and Facebook SDK 3.1 for iOS, then Facebooks SDK takes care of most of that in it's own.

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