I’ve ever found a solution on StackOverflow. But this time I browsed through too much info and I didn’t find an answer for my problem… so here’s my first question:
I’ve been working on a login for my app. There are three main components:
On the App:
* Facebook Login, no custom button, just using FBLoginButton they provide.
* Custom Login: standard email + password login.
On the back-end:
* AWS Cognito to handle the transition between guest and authenticated users. Providing credentials to each user (Guest, Custom or Facebook).
Note: Using Federated identities, not the new User Pools feature, it is still in beta and also not available on my region.
The custom login seems to be working fine. This is the expected (and usual) behavior:
1. First time user opens the app, he/she gets the guest identity within it’s credentials.
2. Only when needed, the user is prompted to login.
3. After setting their email/password on the signup form, our backend generates a new identity and Cognito links the previous identity to a new one which has the developer login in it.
4. If every thing went ok, the user receives the new temporary credentials.
5. Then the user can logout or just leave the app on background without logout.
6. The next time the app try to handle the refresh of the credentials, so the user can continue using the app until logout occurs. In that case if everything goes fine there is no need to show the login process to the user again.
7. In the logout case (as cognito doesn’t allow us to get back the guest state) we should wipe all the credentials and user related info. (Any suggestion/improvement on this would be appreciated also,although is not the main question :P)
Then, I’m trying to achieve the same behavior with Facebook login. The problem I’m facing is that every time my user restart the app, I haven’t found a way to continue the last session with the related problems that suppose:
1-4. Steps 1 to 4 goes fine for the first time.
5. Then the user logouts or backgrounds the app. Remember that at that point my user has a authenticated credentials from Cognito, and I’m not able to come back to guest user, it is not allowed.
Next time the user opens the app, I try to resume the session with my Amazon Client Manager. It detects that previously the user logged in with Facebook and continues with the Facebook login. But here when I ask for: [FBSDKAccessToken currentAccessToken] to authenticate my user with Cognito, the currentAccessToken property is nil.
The only way to login the user is to show the login button again (that’s bad UX) but I realized that, even when I’ve authorized the app permissions on Facebook the first time, the Facebook login web view is presented again forcing the user to accept and already authorized message by Facebook. This should be an unnecessary step. Thats an screenshot what I mean:
I want my user to login seamlessly through Facebook without having to prompt every time with the permissions flow if he has already done it, and the permissions I’m asking for are still accepted.
I’m using the current Facebook sdk (v4.11.0) for iOS. And followed all the steps on the Facebook and AWS documentation. Here are some code snippets and screenshot of what I described:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//return YES;
[FBSDKLoginButton class];
[FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
{...}
return [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
[FBSDKAppEvents activateApp];
[FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url, NSError *error) {
{...}
}}];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
}
I've also modified the info.plist file and added the app transport security for iOS9, and checked twice. My app should run on iOS 8.0+ devices.
I came through dozens of similar questions on StackOverflow. But no one worked for me. And as I haven’t the exact issue (Facebook + Cognito) I though it could be a good question. This is the most similar question I've found:(Without Cognito stuff)
And here are some examples:
Facebook Integration v4.0 Not Working for iPhone App
Reliable check for active session on app startup in Facebook iOS SDK v4.0
http://www.andrewkouri.com/swift-1-2-and-facebooks-new-login-sdk/
Queastions about the AWS Cognito identityId and its generation, uniqueness?
FBSDKAccessToken currentAccessToken nil after quitting app
FBSDKAccessToken currentAccessToken is not being updated after log in
All seems to point to
[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]
Which in my case I was able to test that it returns "NO". Not sure of the implications of that.
Sorry for my english! :P
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire