This is the official plugin for Facebook in Apache Cordova/PhoneGap!
The Facebook plugin for Apache Cordova allows you to use the same JavaScript code in your Cordova application as you use in your web application. However, unlike in the browser, the Cordova application will use the native Facebook app to perform Single Sign On for the user. If this is not possible then the sign on will degrade gracefully using the standard dialog based authentication.
- Supported on PhoneGap (Cordova) v3.5.0 and above.
- This plugin is built for
- iOS FacebookSDK 3.21.1
- Android FacebookSDK 3.21.1
- GitHub URL : https://github.com/Wizcorp/phonegap-facebook-plugin/
Installing this plugin directly from Cordova Registry results in Xcode using a broken FacebookSDK.framework
, this is because the current publish procedure to NPM breaks symlinks CB-6092. Please install the plugin through a locally cloned copy or re-add the FacebookSDK.framework
to Xcode after installation.
To use this plugin you will need to make sure you've registered your Facebook app with Facebook and have an APP_ID
https://developers.facebook.com/apps.
platforms/android
and platforms/ios
contain example projects and all the native code for the plugin for both Android and iOS platforms. They also include versions of the Android and iOS Facebook SDKs. These are used during automatic installation.
facebookConnectPlugin.login(Array strings of permissions, Function success, Function failure)
NOTE : Developers should call facebookConnectPlugin.browserInit(<appId>)
before login - Web App ONLY (see Web App Guide)
Success function returns an Object like:
{
status: "connected",
authResponse: {
session_key: true,
accessToken: "<long string>",
expiresIn: 5183979,
sig: "...",
secret: "...",
userID: "634565435"
}
}
Failure function returns an error String.
facebookConnectPlugin.logout(Function success, Function failure)
facebookConnectPlugin.getLoginStatus(Function success, Function failure)
Success function returns an Object like:
{
authResponse: {
userID: "12345678912345",
accessToken: "kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn",
session_Key: true,
expiresIn: "5183738",
sig: "..."
},
status: "connected"
}
For more information see: Facebook Documentation
facebookConnectPlugin.showDialog(Object options, Function success, Function failure)
Example options - Feed Dialog:
{
method: "feed",
link: "http://example.com",
caption: "Such caption, very feed."
}
App request:
{
method: "apprequests",
message: "Come on man, check out my application."
}