Ionic AccountKit Integration: This article, we're going to learn "How to authenticate user using SMS / Phone Number by Facebook AccountKit"
Requirements:
Create Client Token on Developer's Account
Login with https://developers.facebook.com
Create new project
ionic start accountkit blank
Adding Platform
ionic cordova platform add android
ionic cordova platform add ios
Adding Plugin (Replace with your details)
ionic cordova plugin add cordova-plugin-accountkit --save \
--variable APP_ID="767XXXXXXX58358" \
--variable APP_NAME="CodeSundxxxxx" \
--variable CLIENT_TOKEN="6d97e93101b1681dfcb868xxxxxxx" \
--variable API_VERSION="v1.1"
Adding Button on home.html
<div>PhoneNumber: {{userInfo.country_code}}{{userInfo.phoneNumber}}</div>
<button ion-button color="primary" (click)="register()">Register</button>
Working with home.ts
register(){
(<any>window).AccountKitPlugin.loginWithPhoneNumber({
useAccessToken: true,
defaultCountryCode: "IN",
facebookNotificationsEnabled: true,
}, data => {
(<any>window).AccountKitPlugin.getAccount(
info => this.userInfo = info,
err => console.log(err));
});
}
Facing any issues? feel free to comment below.