Compatibility
- 1.0.0, 1.1.0-alpha1, and main5.35.25.15.04.2
- 1.0.0, 1.1.0-alpha1, and mainiOSmacOS(Intel)macOS(ARM)LinuxtvOSwatchOS
iOS near drop in replacement for Facebook SDK if you only need Facebook Login and no other features (SPM).
Not yet production tested but a very simple minimal replacement for the Facebook SDK that is not just a privacy monster but capable of bringing half the apps on the planet to a crashing halt at launch. It should also reduce app download sizes by some megabytes.
Feature set is limited to logging in and out in a very similar way to the FacebookSDKs plus basic GraphRequest functionality although that GraphRequest feature has not been tested in any way at all at the point of committing it but it builds and launches in a project I tried it in with these additional features/tweaks.
Naming is because I don't like Mark Zuckerburg.
It depends only on iOS frameworks, no third party packages but you do need to inject some closures to make it functional.
It uses an ASWebAuthenticationSession for an nice experience on iOS 12+ and falls back to pushing to a web browser and back for lower versions*.
Thanks to @marinbenc for his article Implementing Facebook Login on iOS without Facebook SDK on which this development was based.
Thanks also to the Facebook Ops teams whose recent outage triggerings have given me great hope that I can persuade clients to remove the Facebook SDK from Apps for the privacy benefit of the users, to ease my conscience having integrated it for them in the first place and
import FMZDropInMinimalFacebookLogin
MinimalFacebook.currentConfig =
MinimalFacebook.Config(
getTokenStringFromKeychain: { keyChain.getString(key: "FacebookLoginTokenString") },
setTokenStringToKeychain: {
if let token = $0 {
_ = keyChain.setString(token, key: "FacebookLoginTokenString")
} else {
keyChain.removeString(key: "FacebookLoginTokenString")
}
},
openUrl: { UIApplication.shared.open($0, options: [:]) })
Optionally but recommended you should check that tokens are still valid for logged in users. This runs that in 10s so that it happens after all you initial launch logic. It will invalidate the token if the user has been logged out.
if AccessToken.current != nil {
DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
MinimalFacebook.validateCurrentToken()
}
}
You need to provide closures to openUrls (for iOS 9,10,11) and also to read and write to the keychain (because the Apple APIs
are clunky and I didn't want to add another dependency when you already likely have wrappers in your project). The
setTokenStringToKeyChain
closure should remove the value when a nil argument is passed in.
On iOS 10 in the Simulator login was failing as the app was not reopening with the URL. I have not investigated deeply, user base on iOS shoud be pretty low at this point.
I'm definitely interested in any fixes and also compatibility enhancing updates. Initially I've developed it against the needs of a single project and if some minor additions help others that would be great but I do want to keep it minimal for small app size and for reviewability.
Feel free to write some. The tricky bits are integration with the app launch and with the Facebook server so the necessary tests aren't obvious to me. But please do try out all scenarios you can think of and feel free to let me know.
I'm @jl_hfl on Twitter, let me know what you think. Please boycott and defund Facebook as much as possible. This is intended to be a tool to help people and apps migrate away and I'm keen to support if you are using it in that context.