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
- A Facebook App created in the Meta for Developers portal
- Basic knowledge of mobile app development
Step 1: Create a Facebook App
- Go to Meta for Developers
- Click My Apps → Create App
- Select Consumer or None as app type
- Enter your app name and contact email
- Click Create App
Step 2: Add Facebook Login Product
- In your app dashboard, click Add Product
- Find Facebook Login and click Set Up
- Select iOS and Android platforms
Step 3: Get Your Credentials
App ID
- Go to Settings → Basic
- Copy the App ID
Client Token
- Go to Settings → Advanced
- Scroll to Security section
- Copy the Client Token
Client Token Required
The Client Token is different from the App Secret. Make sure you copy the Client Token, not the App Secret.
Step 4: Configure Platform Settings
iOS Platform
- In Meta for Developers, go to Settings → Basic
- Scroll to iOS section (or click Add Platform → iOS)
- Enter your Bundle ID (e.g.,
com.yourcompany.martfury) - Enable Single Sign On
- Click Save Changes
Android Platform
- In the Android section (or click Add Platform → Android)
- Enter your Package Name (e.g.,
com.yourcompany.martfury) - Enter Class Name:
com.yourcompany.martfury.MainActivity - Add Key Hashes:bash
# For debug keystore (Mac/Linux) keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 # For debug keystore (Windows) keytool -exportcert -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore | openssl sha1 -binary | openssl base64 - Enable Single Sign On
- Click Save Changes
Multiple Key Hashes
Add key hashes for both debug and release keystores. You may also need to add key hashes for Google Play App Signing if you use it.
Step 5: Configure Your Mobile App
Environment Variables
Create or update your .env file:
# Facebook Sign-In credentials
FACEBOOK_APP_ID=your_facebook_app_id
FACEBOOK_CLIENT_TOKEN=your_facebook_client_token
# Enable Facebook Sign-In
ENABLE_FACEBOOK_SIGN_IN=trueiOS Configuration
Update your ios/Runner/Info.plist with your Facebook credentials:
<!-- Facebook URL Scheme -->
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbYOUR_APP_ID</string>
</array>
</dict>
</array>
<!-- Facebook App Configuration -->
<key>FacebookAppID</key>
<string>YOUR_APP_ID</string>
<key>FacebookClientToken</key>
<string>YOUR_CLIENT_TOKEN</string>
<key>FacebookDisplayName</key>
<string>Your App Name</string>
<!-- Required for Facebook SDK -->
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
</array>Replace the placeholders:
fbYOUR_APP_ID→fb123456789(prefixfb+ your App ID)YOUR_APP_ID→ Your Facebook App IDYOUR_CLIENT_TOKEN→ Your Facebook Client TokenYour App Name→ Your app's display name
Android Configuration
The flutter_facebook_auth package handles Android configuration automatically through the build system. No manual AndroidManifest.xml changes are required.
The package reads credentials from your Flutter configuration at build time.
Step 6: Set App Mode
For testing, your app can be in Development mode. For production:
- Go to App Review → Permissions and Features
- Request necessary permissions (email is usually sufficient)
- Complete the Data Use Checkup
- Toggle your app from Development to Live mode
Development Mode Limitations
In Development mode, only users listed as Testers, Developers, or Administrators can log in. Add test users in Roles section.
Step 7: 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
1. Facebook Login button not showing
- Verify
ENABLE_FACEBOOK_SIGN_IN=truein your.envfile - Ensure both
FACEBOOK_APP_IDandFACEBOOK_CLIENT_TOKENare set - Restart the app completely (hot reload doesn't apply
.envchanges)
2. "Invalid key hash" error on Android
- Generate key hash using the command above
- Add it to your Facebook app's Android settings
- For Google Play App Signing, get the key hash from Play Console
3. "App Not Setup" or "App in Development Mode"
- Your Facebook app is in Development mode
- Add your Facebook account as a Tester/Developer in the app's Roles section
- Or switch the app to Live mode (requires completing App Review)
4. Login fails with "GraphRequest" error
- Check that Client Token is correct (not App Secret)
- Verify App ID matches between
.envand Info.plist - Ensure Facebook app has required permissions
5. iOS: "Cannot open Facebook app"
- Verify
LSApplicationQueriesSchemesis properly configured in Info.plist - Check that the URL scheme
fbYOUR_APP_IDis correct
6. Login works but user data is incomplete
- Check permissions in your Facebook app settings
- Default permissions only include
public_profile - Request
emailpermission if needed
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
- Never expose your App Secret in client-side code
