Facebook Account Kit login queries...Please help!


#1

Hi All, I am trying to integrate facebook account kit login in my ionic android app. I have installed following things.

  1. cordova plugin add cordova-plugin-facebook-account-kit --save --variable APP_ID=“XXXXXXX” --variable APP_NAME=“XXXX” --variable AK_TOKEN=“XXXXXXXXXXXXXXXXXXXXXXX”
  2. npm i cordova-plugin-facebook-account-kit

Below is my code snippet. The below code throws me account kit login page. The problem is:

  1. . How to set the default country code while throwing the page (for ex: +852 for hongkong)
  2. How to do logout functionality

I am confused by what is written in npm sites as I am not sure why there are so many plugins for account kit. Kindly, if any body has any working code, please help. Thanks.

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';



declare var FacebookAccountKit:any; 

@Component({

  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  result: any;
  test: any;
  userDetail: any;
  constructor(public navCtrl: NavController) {

  }
  success (response: any){
    
        console.log(response);
        this.result = response;
  //      this.navCtrl.push('OnboardLocationPage');
       this.test = this.result;
    }
    
    error(err) {
        console.log(err);
        this.test = err;
    }
    
    smsLogin() {
        FacebookAccountKit.mobileLogin(function (response) 
        { alert(JSON.stringify(response)); }, function (error) { console.log(error) });
  
   }   
}


#2

Hi Anyone to help in this please…


#3

Hi to login with a phone number you should use this function:

AccountKitPlugin.loginWithPhoneNumber( 
   Object options, 
   Function success, 
   Function failure
)

To logout:

AccountKitPlugin.logout()

for exemple I live in KSA the code country is : SA

phonelogin(){
    (<any>window)
      .AccountKitPlugin
        .loginWithPhoneNumber({
          useAccessToken: true,
          defaultCountryCode: "SA",
          facebookNotificationsEnabled: true
        }, (successdata) => {
          (<any>window).AccountKitPlugin.getAccount((user) => {
            console.log( JSON.stringify(user) );
            
          })
        }, (err) => {
          alert(err);
        })
  }

some doc:
https://www.npmjs.com/package/cordova-plugin-accountkit