The Apache Cordova wrapper around the Facebook AccountKit.
- Create Facebook Developer Account
- Get a Facebook App ID (
APP_ID
) - Get an AccountKit client token (
CLIENT_TOKEN
) - To install the plugin in your app, execute the following (replace variables where necessary):
cordova plugin add cordova-plugin-accountkit --save \
--variable APP_ID="123456789" \
--variable APP_NAME="myApplication" \
--variable CLIENT_TOKEN="abcdefghijklmnopqrstuvwxyz" \
--variable API_VERSION="v1.1"
If you need to change your APP_ID
after installation, it's recommended that you remove and then re-add the plugin as above. Note that changes to the APP_ID
value in your config.xml
file will not be propagated to the individual platform builds.
If you want to use Access Tokens flow with this plugin, you have to set Enable Client Access Token Flow in your app's dashboard to ON (for more information on Client Access Token Flow, see Access Tokens and Authorization Codes).
It is recommended to add these permission to config.xml
of your Cordova project to reduce the friction during the login process (more info):
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
AccountKitPlugin.loginWithEmail(Object options, Function success, Function failure)
Available options:
{
useAccessToken: true,
defaultCountryCode: "US",
facebookNotificationsEnabled: true,
initialEmail: "[email protected]"
}
Available country codes can be found here.
Success function returns an Object like:
{
accountId: "<string>",
applicationId: "<string>",
token: "<long string>",
lastRefresh: 1451606400,
refreshInterval: 2592000
}
If you do not use access tokens an Object looks like:
{
code: "<long string>",
state: "<string>"
}
Failure function returns an error String.
AccountKitPlugin.loginWithPhoneNumber(Object options, Function success, Function failure)
Available options:
{
useAccessToken: true,
defaultCountryCode: "US",
facebookNotificationsEnabled: true,
initialPhoneNumber: ["420", "123456789"]
}
Available dialing codes and country codes can be found here.
Success function returns an Object like:
{
accountId: "<string>",
applicationId: "<string>",
token: "<long string>",
lastRefresh: 1451606400,
refreshInterval: 2592000
}
If you do not use access tokens an Object looks like:
{
code: "<long string>",
state: "<string>"
}
Failure function returns an error String.
AccountKitPlugin.logout()
This method only works when login method was called with { useAccessToken: true }
.
AccountKitPlugin.getAccount(Function success, Function failure)
Success function returns an Object like:
{
accountId: "<string>",
applicationId: "<string>",
token: "<long string>",
lastRefresh: 1451606400,
refreshInterval: 2592000,
email: "<string>",
phoneNumber: "<string>"
}