roughike/flutter_facebook_login

Is there a way to dynamically set the App ID fo facebook login?

Closed this issue · 8 comments

Is there a way to dynamically set the App ID fo facebook login?

Both iOS and Android provide a way to explicitly set the app id.
Android has FacebookSdk.setApplicationId(ACTIVE_APP_ID);
and iOS has [FBSDKSettings setAppID:ACTIVE_APP_ID];

How can I accomplish that via this plugin for flutter?

If you add that ability .. there is also displayName
(void)setDisplayName:(NSString *)displayName;

for iOS as an example these methods are all defined in ios/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKSettings.h

Thanks for the suggestion, I'll look into it!

Thanks... I can also try and look into it. Any pointers on how I can help?

Sure!

If you want to do a PR, look into the twitter login plugin for ideas.

The general idea is to construct an instance of the FacebookLogin with the app_id and cache it in the Dart side.

Then with every method call, you basically pass the same app_id to the native side, along with other things the specific method needs. This is just to reduce roundtrips and avoiding any async/await with the construction of the FacebookLogin instance.

In the native side, you just simply initialize the Facebook Login SDK with the app_id you get from Dart side. If the initialization is already done, you just ignore it and return the already initialized client. See the twitter login for a general idea.

Just shoot me with a PR even if it's incomplete and I'll help. :)

@manujbahl I think I'm going to take a look soon, but don't want to do unneeded work if you're already doing something. Are your working on something here, or is it okay for me to take over?

I looked into this in detail just now, and correct me if I'm wrong, but seems like getting rid of the AndroidManifest and Info.plist configuration isn't possible.

While there's a way of setting the app id dynamically, the scheme still needs to be set in AndroidManifest and Info.plist. Intent Filters on Android don't support dynamic setup, and it's a crucial part of the Facebook login process in the case where the user doesn't have the official native Facebook app installed.

The official react native FBSDK from Facebook requiring some Android & iOS specific configuration also seems to support that this kind of thing can't be done.

Feel free to comment if you find me being wrong, and I'll be happy to reopen!