Skip to content

Instantly share code, notes, and snippets.

@josephdicdican
Last active January 30, 2018 06:58
Show Gist options
  • Save josephdicdican/022def9e78915f3b907594aa907d40c7 to your computer and use it in GitHub Desktop.
Save josephdicdican/022def9e78915f3b907594aa907d40c7 to your computer and use it in GitHub Desktop.
Integrate FB to Ionic Project

Integrate FB to Ionic 2

  1. Setup FB App on https://developers.facebook.com/
  2. Create ionic project
# example
$ ionic start myApp tabs
  1. Add cordova-plugin-facebook4
$ cordova plugin add cordova-plugin-facebook4 --variable APP_ID="<app_id>" --variable APP_NAME="<app_name>"
  1. Link config.xml widget id to facebook developer
  2. Define provider codes on your myApp
  3. Run command ionic cordova run browser on your myApp directory to solve issue below. (Issue below will possibly occur when you just run your app using ionic serve)

Error logging into Facebook cordova_not_available

  1. 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)

  1. 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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment