An user can logs in my app with Facebook or with email and password.
When this user shares a content, he could share on Facebook too with explicit sharing (without opening nothing else).
So, when this user logs in with standard way and try to share content on Facebook, he must logs in with Facebook first. Is it possible to link this Facebook user to an existing Backendless user?
So when an existing Backendless user logs in to Facebook, how are you going to handle that login? I assume it would be outside of your app, wouldn’t it?
Yes, sure
When a user logs in to Facebook, you get some information about their social account. You should be able to store it as a custom property of the BackendlessUser object. That would create the link you are looking for.
Are you talking me to store token and FacebookID?
Possibly. Whatever makes sense in the context of your app. What is the ultimate goal here? Why do you need the two linked up?
I have something like Instagram. User could activate the explicit sharing tapping Facebook button. I have to save this possibility in local to make it available for the next sharing. If user logs in to my app with email and password, when he is about to sharing content and decides to activate Facebook sharing, he will prompt in to Facebook login first. After that, I will request for publish permission then share with only one button on both Facebook and my app. Next time, this possibility will be available by default (btw,user can deactivate it)
Thanks for the explanation. Going back to you original question. Any kind of linking between a BackendlessUser and a user from an outside system (like Facebook in this case) can be done through user properties. Does it work for you?
I worked on it and I could obtain the same result using Facebook SDK, without the need of linking Facebook user to Backendless user (just using access token).
But I found another problem: if login is performed in this wayFBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:permissions fromViewController:self.navigationController handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
//NSLog(@"Process error");
} else if (result.isCancelled) {
//NSLog(@"Cancelled");
} else {
NSLog(@"Logged in");
FBSDKAccessToken *token = [FBSDKAccessToken currentAccessToken];
NSDictionary *fieldsMapping = [NSDictionary dictionaryWithObjectsAndKeys:
@"email",@"email",
nil];
BackendlessUser *user = [backendless.userService loginWithFacebookSDK:token fieldsMapping:fieldsMapping];
}
}];
then accessToken is null.
If I remove the code to log in an BackendlessUser
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:permissionsArray fromViewController:self.navigationController handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
//NSLog(@"Process error");
} else if (result.isCancelled) {
//NSLog(@"Cancelled");
} else {
//NSLog(@"Logged in");
}];
the method returns a valid accessToken…
Why?
It sounds like when you use Facebook login without any Backendless code, it does not work for you?
Facebook login only gives me the accessToken. Then if I login Backendlessuser with that accessToken, the completion gives me a null accessToken.
Login to Facebook should be giving you BackendlessUser and not access token.
Ok, and now I would like to check if BackandlessUser (logged with Facebook) has granted the publish permission and, if no, ask for it?
sure. That information could be stored in a user property.