Zahidur Rahman
Zahidur Rahman

Reputation: 1718

Facebook Account Kit in Ionic/Cordova app

I try to connect Facbook Account Kit in Ionic/cordova App, main problem i faced that in facebook account kit set client/server side domain name but in ionic/cordova app the webview serve from file system("file:///android_asset/www/index.html#/app/request"). So how to do this in Ionic app.

Upvotes: 8

Views: 3091

Answers (1)

Sundaravel M
Sundaravel M

Reputation: 246

You can use plugin instead of webview https://github.com/gurisko/cordova-plugin-accountkit

Steps:

  1. Create a Facebook application from https://developers.facebook.com
  2. Enable Accountkit; Copy required credentials
  3. Add AccountKit plugin

cordova plugin add cordova-plugin-accountkit --save --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable CLIENT_TOKEN="abcdefghijklmnopqrstuvwxyz"

AccountKitPlugin.loginWithPhoneNumber({
    useAccessToken: true,
    defaultCountryCode: "US",
  },function(res){
    console.log(res)
  },function(err){
     console.log(err)
})

Incase of Ionic with typescript just add (window) before function

(<any>window).AccountKitPlugin.loginWithPhoneNumber({
    useAccessToken: true,
    defaultCountryCode: "US",
  },function(res){
    console.log(res)
  },function(err){
     console.log(err)
})

Reference: https://codesundar.com/ionic-accountkit-integration/

Upvotes: 2

Related Questions