- Setup FB App on https://developers.facebook.com/
- Create ionic project
# example
$ ionic start myApp tabs
- Add
cordova-plugin-facebook4
$ cordova plugin add cordova-plugin-facebook4 --variable APP_ID="<app_id>" --variable APP_NAME="<app_name>"
- Link
config.xml
widget id to facebook developer - Define provider codes on your
myApp
- Run command
ionic cordova run browser
on yourmyApp
directory to solve issue below. (Issue below will possibly occur when you just run your app usingionic serve
)
Error logging into Facebook
cordova_not_available
- Try logging in (if you're not that lucky, you will meet this issue below)
Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.
Solution:
Add platform
Website
on your fb app (https://developers.facebook.com/apps/)
Example: http://localhost:8000/
for local testing (ionic cordova run browser
)
- Try again, it should work. You will see example response if success.
{
"authResponse": {
"userID": "12345678912345",
"accessToken": "kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn",
"session_Key": true,
"expiresIn": "5183738",
"sig": "..."
},
"status": "connected"
}
Resources: