v2.4.0-alpha03
·
18 commits
to main
since this release
What's Changed
- Feat: Facebook Login Integration by @BattlefieldNoob in #134
- Add missing dependency on
kmpauth-coretokmpauth-firebaseby @ChristianKatzmann in #127 - Bumping dependency versions by @mirzemehdi in #137
New Contributors
- @BattlefieldNoob made their first contribution in #134
- @ChristianKatzmann made their first contribution in #127
Full Changelog: v2.4.0-alpha02...v2.4.0-alpha03
Facebook Auth Support
This release adds support for Facebook Login with Firebase authentication in Android and iOS using KMPAuth.
Usage Example
//Facebook button with icon
FacebookButtonUiContainer(
onResult = { result -> /* handle FirebaseUser result or error */ },
linkAccount = false
) {
FacebookSignInButtonIconOnly(onClick = { this.onClick() })
}
//Icon Only Button
FacebookButtonUiContainer(
modifier = Modifier.fillMaxWidth().height(44.dp),
onResult = { result -> /* handle result */ },
linkAccount = false
) {
FacebookSignInButton(fontSize = 19.sp) { this.onClick() }
}
//Custom Button
FacebookButtonUiContainer(
modifier = Modifier.fillMaxWidth().height(44.dp),
onResult = { result -> /* handle result */ },
linkAccount = false
) {
//Your custom Button here
YourCustomButton(fontSize = 19.sp) { this.onClick() }
}
Android Setup
Add these to your res/values/strings.xml:
<string name="facebook_app_id">YOUR_FACEBOOK_APP_ID</string>
<string name="fb_login_protocol_scheme">fbYOUR_FACEBOOK_APP_ID</string>
<string name="facebook_client_token">YOUR_FACEBOOK_CLIENT_TOKEN</string>Add these metadata tags and Facebook Activity to your AndroidManifest.xml inside the <application> tag:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="@string/facebook_client_token" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />For Facebook Login, on Your Main Activity's activity result call KMPAuth.handleFacebookActivityResult function:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
KMPAuth.handleFacebookActivityResult(requestCode, resultCode, data)
super.onActivityResult(requestCode, resultCode, data)
}IOS Setup
Add Facebook Login SDK Swift Package, and add below to your Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbFACEBOOK_APP_ID</string> <!-- Your Facebook App ID with 'fb' prefix -->
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>FACEBOOK_APP_ID</string>
<key>FacebookClientToken</key>
<string>YOUR_FACEBOOK_CLIENT_TOKEN</string>
<key>FacebookDisplayName</key>
<string>YourAppDisplayName</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
Initialize Facebook SDK on Ios Swift side
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
FirebaseApp.configure()
// Initialize Facebook SDK.
FBSDKCoreKit.ApplicationDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)
return true
}
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
var handled: Bool
handled = FBSDKCoreKit.ApplicationDelegate.shared.application(
app,
open: url,
options: options
)
if handled {
return true
}
return false
}Notes
- You must configure your Facebook App in Facebook Developers Console properly and enable Firebase Facebook provider.
- This release currently supports Android and iOS only.
- Facebook Login for iOS - https://developers.facebook.com/docs/facebook-login/android
- Facebook Login for Android - https://developers.facebook.com/docs/facebook-login/ios
- Firebase Authentication with Facebook - https://firebase.google.com/docs/auth/android/facebook-login
- Firebase Authentication with Facebook iOS - https://firebase.google.com/docs/auth/ios/facebook-login