Skip to content

Conversation

cruzach
Copy link
Contributor

@cruzach cruzach commented Apr 20, 2020

Why

(1) Closes #6459
and (2) closes #6112

(1) Currently, Facebook Login in the Expo Client on iOS does not redirect back to the experience after selecting to "Login via the Facebook app." Instead, the user is left with a blank white screen with Cancel at the top left.

(2) In standalone apps (and the Expo Client once (1) is addressed), after calling Facebook.loginWithReadPermissionsAsync & signing in with the facebook app, the webbrowser window occasionally remains open after the native facebook app redirects back to the standalone app after the user has logged in, thus users can never log in. This is because UMAppDelegateWrapper is iterating over the subcontractors looking for a viable openURL method. Sometimes ExpoKitAppDelegate is first in the set, other times EXFacebookAppDelegate is first. Since ExpoKitAppDelegate always returns YES for openURL, if it’s first in that list, it attempts to (and says it has successfully) open the FB url, but it should not

How

(1) By adding the fbid url scheme, the FacebookAppId, and the required LSApplicationQueriesSchemes from Facebook's documentation, the redirect is now successful. The scoped facebook module now also automatically uses the Expo Client's facebook app id, even if the user provides one. This way, developers don't have to remember to change their app id in place of a "development" app id (Expo's) when they build or publish for release, they can write the method once and forget about it.

(2) By adding a priority property to singleton modules, which defaults to 0, we can re-order the subcontractors to match this priority. So UMAppDelegateWrapper would order unimodules:
n , … , 1, [all the 0s in whatever order], -1, -2, ..., -n

Test Plan

Tested in a local client build with app.json facebook configuration, and without (but providing in the Facebook.initializeAsync call)

Confirmed that ExpoKitAppDelegate is always last in the array of subcontractors

@cruzach cruzach requested a review from sjchmiela April 20, 2020 21:24
Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this issue, it giving us and the developers a hard time for so long… 😃

What are the consequences of using Expo's Facebook app for all API calls in Expo Client? Should we list them in the documentation? We should probably also put that information somewhere around a list of breaking changes introduced in SDK37.

Could you also please add some people from the SWM team to the Expo Client Facebook app, so in case something goes wrong we can at least look into the settings and see if everything is configured as it should?

<string>fbapi20150629</string>
<string>fbapi20160328</string>
<string>fbauth</string>
<string>fb-messenger-share-api</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need https://github.com/expo/expo-cli/blob/6bacea668e954c24eb8d9ed6d46a5c46bc3e4a2f/packages/xdl/src/detach/IosNSBundle.ts#L317-L322? Should we .uniq() the array before building the app, add/remove some entries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm so it seems the facebook docs are conflicting a little bit:

  • when setting up the app it at the facebook developer console it says to include all of these (it know's we use FB SDK v5)
  • but here it says that the fbapi.* schemes are only if you are on FB SDK v4.5 or older

I haven't noticed any issues when excluding the schemes, so probably safe to remove them

@cruzach cruzach changed the title [ios][facebook] allow Facebook login in Expo Client [ios][facebook] add schemes for facebook login & always handle openURL in EXFacebookAppDelegate Apr 23, 2020
@cruzach cruzach requested a review from sjchmiela April 23, 2020 03:08
@cruzach
Copy link
Contributor Author

cruzach commented Apr 23, 2020

What are the consequences of using Expo's Facebook app for all API calls in Expo Client?

The main drawback is that they won't see app events logged, since their app isn't being initialized. Possibly also ramifications for facebook ads, since that relies on facebook app id as well

Could you also please add some people from the SWM team to the Expo Client Facebook app, so in case something goes wrong we can at least look into the settings and see if everything is configured as it should?

Absolutely, I just need their facebook user name (found by navigating to your facebook profile page, and checking the URL- facebook.com/<user-name> )

Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look great, great job! 👍

@@ -6,6 +6,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface UMSingletonModule : NSObject

@property (nonatomic) int priority;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make it either a readonly property or a method? This way we'd make it obvious that the only way to override value for this property is through subclassing, not manipulating the object. We could provide a default implementation for the method in UMSingletonModule.m.

Could we also make it an NSInteger? I think it's more Objective-Cy. 🤔


NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"priority"
ascending:NO];
[subcontractors sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@@ -48,15 +48,16 @@ - (instancetype)initWithExperienceId:(NSString *)experienceId andParams:(NSDicti
BOOL hasPreviouslySetAutoInitEnabled = [_settings boolForKey:AUTO_INIT_KEY];
BOOL manifestDefinesAutoInitEnabled = [params[@"manifest"][@"facebookAutoInitEnabled"] boolValue];

NSString *facebookAppId = params[@"manifest"][@"facebookAppId"];
NSString *scopedFacebookAppId = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FacebookAppID"];
UMLogInfo(@"Overriding Facebook App ID with the Expo Client's. To test your own Facebook App ID, you'll need to build a standalone app. Refer to our documentation for more info- https://docs.expo.io/versions/latest/sdk/facebook/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to always log that information when the experience is starting? Maybe only if user defines his/her own FacebookAppID (if so, they may expect Expo Client to use it) would suffice?

Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Looks super great to me! 🎉

@cruzach cruzach merged commit b5c35b9 into master Apr 24, 2020
@cruzach cruzach deleted the @cruzach/fb-login-client branch April 24, 2020 18:31
cruzach added a commit that referenced this pull request Apr 24, 2020
@appsgenie
Copy link

does anyone know how we can get this fix into our existing projects? or what the current status is for this fix to get released?

@jeanlucnguyen
Copy link

Since the Facebook APP ID used now is always the one from Expo when using Expo Client, it seems that we can't have access to user_friends, user_birthday or user_gender permissions anymore. This used to work well when we could use our own APP ID. Also, being forced to use Expo App Id prevents us from using Facebook Test Users feature as well. Isn't it possible to leave an option to be able to use our own Facebook App Id in development when using Expo Client? We never had the problem referenced in this issue before so this seems like a step back for us.

@atyrian
Copy link

atyrian commented May 9, 2020

Hi. I am quite new to development, so forgive me if this is not the right forum.

Today I noticed that the permissions that I had previously granted to my application via Facebook's developer portal were no longer effective (user_gender, user_birthday, user_photos). The User ID of my user also changed (I presume this is scoped to the app). After reading the changelog for SDK 37 I now understand that the reason being the user token is issued in the scope of Expo Client instead of the app that I have registered with Facebook.

Is this with the understanding that I may now only use the default public profile permissions, or is there some other way of getting more granular permissions? My application relies very heavily on being able to fetch user images. My understanding is that I should now build my app as a Standalone application (something that I would have to do to distribute the app on the app store anyways?) as per the SDK 37 documentation.

Thank you for any help in this matter.

@cruzach
Copy link
Contributor Author

cruzach commented May 11, 2020

@atyrian that's correct, you should build your app as a standalone IPA (you can also test using simulator builds) if you want to use your own Facebook app ID

@jeanlucnguyen it seems like those particular permissions, along with a couple other features, require app review, I'll look into that. As for Test Users, it seems like that may be a feature not available in the Expo Client app. But I think having a functioning Facebook Login is more critical than access to the test users feature in the expo client app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants