I am creating an app on iOS that requires a user to login with their google account, but it needs to remember the user for a later time without any user input. For example, if a person quit and reopened the app, it will remember their username and password (or that it has already been verified) and send the user directly into the app. How do I go about accomplishing this?
[[GIDSignIn sharedInstance] signInSilently];
Google uses OAuth for that kind kind functionality. Here's their guide on how to do it.
Related
I would like to know if there is a way to find out before I send the authorization request if a user is signing up to my app with Apple for the first time, or if he/she is already registered and just signs in.
Basically I have a registration screen in my app, where a user can create two types of users and a login screen where both users can log in. I would like to keep the registration and login separate, so for that I need to know whether its a first sign in with apple.
I'm not sure what database you're using but for Cloud Firestore there is a Sign-in method that can be used with Apple.
I am developing iOS App which use Facebook iOS SDK 4.
When user has already done Facebook login, by doing Facebook login the dialog which shows "user has already approved your app" had be displayed.
So, do not show the dialog. I want to know whether the user has already done Facebook login.
Anyone know the good way? I think accessToken is returned if user once had done Facebook login.
FBSDKAccessToken manage current logged user's accessToken.
According to official Facebook Login guide
"FBSDKAccessToken Represents the access token provided by a successful login. Most important, it provides a global +currentAccessToken to represent the currently logged in user."
The currentAccessToken is a convenient representation of the token of the current user and is used by other SDK components (like FBSDKLoginManager).
According to above you can check either user has valid accessToken or not and based on this you can track call login method otherwise just skip to next flow.
In Facebook the access tokens are per user so you can pass them around apps and they will work. In your case if you can ship an access token from another app you will be able to skip the next logging in and use the API normally.
However I think this this thread will help you.
Things are a little bit different with iOS cause I have done a facebook login on Android and got no such issues.
I'm using, with success the Fabric Login button (TWTRLogInButton, https://dev.twitter.com/twitter-kit/ios-reference/twtrloginbutton).
In my Swift app I can authenticate myself, make calls and all. The only problem is that i've implemented a "Logout" button that calls Twitter.logOut().
As specified by the documentation (https://dev.twitter.com/twitter-kit/ios-reference/twitter) this deletes the local session but does not invalidate the remote session. The effect is that once I'm authenticated and then logged out, if I click the "Login" button again I'm logged-in again with the same user, effectively preventing me from switching user.
Any help?
The logOut is a class method, did you call:
Twitter.sharedInstance().logOut()
The incomplete logout issue you guys are facing is actually more related to iOS persisting system accounts. TwitterKit automatically logs a user in if they were already logged in on iOS. You can workaround this behavioral in the use case of kiosk with these steps:
Login to Twitter in Settings > Twitter
Switch to your app and attempt to login with Twitter
Disallow access to Twitter accounts when the grant access dialog comes up:
This prevents TwitterKit from accessing your system accounts and every user will have to login. Hope this helps!
(Initially Twitter.sharedInstance().logOut() destroys local session...)
use method
[[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBasedForceLogin completion:{}]
Parameter TWTRLoginMethodWebBasedForceLogin
Presents a web view that doesn't use any cached sessions
from Safari. Allows the developer to provide multi-user
functionality with several Twitter accounts.
I came across this problem as well, but it seems that this is how it behaves, Twitter "saves" the credentials on an OS level using Accounts
framework. You can see this here:
go to Settings on your phone -> Twitter and you'll see the account there go into the account and "Delete Account"
once you delete the account you will find that when you launch your app and try to login to twitter now you will be asked to sign in.
Once an account is added there is no way to take out the account, (unless Twitter supports this and makes it public) The User will have to manually go into Settings -> Twitter and delete the account from there to be able to sign in to a different account.
Also i noticed that when you add another account into Twitter, trying to login you will be given a chance to login either account when using
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error)
edit: Upon further Research if the User allows the app to use "Twitter" accounts you are able to access the Accounts Framework and delete the account from there:
https://developer.apple.com/library/mac/documentation/Accounts/Reference/ACAccountStoreClassRef/index.html
Cheers!
I recently have a problem for my Facebook integration into my app.
I want the app to be able to ask for user to type in their username and password every time they want to connect to Facebook, I tried the example that comes in the Facebook SDK "switch User", but I still have some problems in integrating the function into my app.
Could anyone help me out? Thanks!
Use FBLoginView it will display a Login Button for Logging in with FBSDK and during logout functionality in your product, write this: [FBSession.activeSession closeAndClearTokenInformation]; and then dipslay the FBLoginView so that it will allow user to relogin into your product.
thanks for answering my question. I finally solved the problem by creating a button and add a IBAction to perform the log in/out, and when user is trying to login, I open the session by using the FBSessionBehaviorForcingWebView, which will allow different users to log in since it asks user for email & password every time.
If I want to make sure that the ios app has access to user's facebook account, which method should I follow? I have seen checking for FBSession.accessToken in some places and FBSession.activeSession.isOpen being checked at some other places. What is the difference between these two?
Thanks.
If you want to communicate with Facebook via your app and considering that you have setup the project correctly i.e. the FacebookAppID etc, you call for an active session via
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI
method. The access token stores the information that an app has been permitted with certain permissions your app asks and you check for a valid access token each time so that you don't have to validate the app each time.
FBSession.activeSession.isOpen is used to check if there is an active session in open state and if so, you can move forward with whatever your app intends to do with Facebook.
FBSession.accessToken tells you that the app has access to the user's Facebook account, whereas FBSession.activeSession.isOpen tells you weather the current session is open or not. We prefer to use FBSession.accessToken to check if the app has access to the user's facebook or not.