Facebook Login Setup Guide for Mobile App
This guide will help you set up Facebook Login in your MartFury mobile app.
Prerequisites
- A Facebook Developer Account
- Basic knowledge of mobile app development
Step 1: Configure Facebook Developer Account
- Go to Facebook Developers
- Create a new app or select an existing one
- Add Facebook Login product to your app
- Configure the Facebook Login settings
- Note down your App ID and App Secret
Step 2: Configure Your Mobile App
Environment Variables
Create or update your .env
file with the following variables:
bash
FACEBOOK_APP_ID=your_facebook_app_id
FACEBOOK_CLIENT_TOKEN=your_facebook_client_token
iOS Configuration
The Facebook Login configuration is already set up in your Info.plist
. Make sure it contains:
xml
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbYOUR_APP_ID</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>YOUR_APP_ID</string>
<key>FacebookClientToken</key>
<string>YOUR_CLIENT_TOKEN</string>
<key>FacebookDisplayName</key>
<string>MartFury</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
</array>
Android Configuration
For Android, you need to add the following to your AndroidManifest.xml
:
xml
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<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" />
And in your app's build.gradle
:
groovy
defaultConfig {
// ...
manifestPlaceholders += [
'facebookAppId': 'YOUR_APP_ID',
'facebookClientToken': 'YOUR_CLIENT_TOKEN'
]
}
Step 3: Testing the Integration
- Run your app
- Go to the login screen
- Tap the Facebook Login button
- Complete the Facebook authentication flow
- Verify that you're redirected back to your app
Troubleshooting
Common Issues
Login fails with "Invalid configuration"
- Verify that your Facebook App ID and Client Token are correct
- Check that your app's bundle ID/package name matches the one in Facebook Developer Portal
- Ensure Facebook Login is properly configured in the Facebook Developer Portal
App crashes on Facebook Login
- Verify that your Facebook credentials are correct
- Check that all required configurations are in place
- Ensure you have an active internet connection
Getting Help
If you encounter any issues:
- Check the Facebook Login Documentation
- Review the flutter_facebook_auth package documentation
- Check your app's logs for detailed error messages
Security Considerations
- Never commit your Facebook App ID and Client Token to version control
- Always use environment variables for sensitive data
- Implement proper error handling and user feedback