Socket
Socket
Sign inDemoInstall

cordova-plugin-facebook4

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-facebook4 - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

docs/browser/LOCALHOST_GUIDE.md

19

docs/browser/README.md

@@ -7,7 +7,7 @@ # Facebook Requirements and Set-Up [Web App]

`www/js/facebookConnectPlugin.js` contains the JavaScript SDK and API file. The API matches as close as possible to the native APIs.
`www/facebookConnectPlugin.js` contains the JavaScript SDK and API file. The API matches as close as possible to the native APIs.
## Example App
For localhost testing on OS X see the [Jekyll guide](guide/JEKYLL_GUIDE.md)
For localhost testing on OS X see the [Localhost guide](guide/LOCALHOST_GUIDE.md)

@@ -32,19 +32,14 @@ ## Install

- You must add the following somewhere in your `index.js`:
```html
<div id="fb-root"></div>
```
- The difference between the JS API and Native is that the Facebook JS SDK must be initiated. Here is an example:
```
```js
if (window.cordova.platformId == "browser") {
facebookConnectPlugin.browserInit(appId, version);
// version is optional. It refers to the version of API you may want to use.
facebookConnectPlugin.browserInit(appId, version, success);
// version is optional. It refers to the version of API you may want to use.
// success is optional. It calls the function when the SDK has been inited
}
```
- In your facebook develop website settings page, add your server's domain to app doamin (or localhost for testing).
- In your facebook develop website settings page, add your server's domain to app domain (or localhost for testing).
![image](app_domain_setup.png)

@@ -19,5 +19,4 @@ # Facebook Requirements and Set-Up [iOS]

# The path you cloned the plugin to earlier
# Remember to replace APP_ID and APP_NAME variables
$ cordova plugin add https://github.com/jeduan/cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication"
$ cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication"
```
{
"name": "cordova-plugin-facebook4",
"version": "1.0.1",
"version": "1.1.0",
"description": "Cordova Facebook SDK 4 Plugin",

@@ -5,0 +5,0 @@ "cordova": {

@@ -1,21 +0,28 @@

# Apache Cordova Facebook Plugin
# cordova-plugin-facebook4
This is a fork of the official plugin for Facebook in Apache Cordova that implements the latest Facebook SDK
> Use Facebook SDK version 4 in Cordova projects
The Facebook plugin for [Apache Cordova](http://cordova.apache.org/) 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.
## Installation
* Supported on PhoneGap (Cordova) v5.0.0 and above.
* This plugin is built for
* iOS FacebookSDK 4.3.0
* Android FacebookSDK 4.3.0
* GitHub URL : [https://github.com/Wizcorp/phonegap-facebook-plugin/](https://github.com/Wizcorp/phonegap-facebook-plugin/)
Make sure you've registered your Facebook app with Facebook and have an `APP_ID` [https://developers.facebook.com/apps](https://developers.facebook.com/apps).
## ------------------------------------------ >>
```bash
$ cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication"
```
------------------------------------------
## Usage
## Facebook Requirements and Set-Up
This is a fork of the [official plugin for Facebook](https://github.com/Wizcorp/phonegap-facebook-plugin/) in Apache Cordova that implements the latest Facebook SDK. Unless noted, this is a drop-in replacement. You don't have to replace your client code.
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](https://developers.facebook.com/apps).
The Facebook plugin for [Apache Cordova](http://cordova.apache.org/) 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.
## Compatibility
* Cordova v5.0.0.
* cordova-android >= 4.0
* cordova-ios >= 3.8
* cordova-browser >= 3.6
Unfortunately, at this time PhoneGap Build is not supported on Android, since this plugin uses Gradle and PhoneGap Build [does not support that yet](http://community.phonegap.com/nitobi/topics/phonegap-build-does-not-support-gradle-builds)
#### Install Guides

@@ -29,4 +36,2 @@

- [PhoneGap Build Guide](docs/pg-build/README.md)
- [Troubleshooting Guide | F.A.Q.](docs/TROUBLESHOOTING.md)

@@ -177,10 +182,13 @@

var fbLoginSuccess = function (userData) {
alert("UserInfo: " + JSON.stringify(userData));
}
```js
var fbLoginSuccess = function (userData) {
console.log("UserInfo: ", userData);
}
facebookConnectPlugin.login(["public_profile"],
fbLoginSuccess,
function (error) { alert("" + error) }
);
facebookConnectPlugin.login(["public_profile"], fbLoginSuccess,
function loginError (error) {
console.error(error)
}
);
```

@@ -190,17 +198,17 @@ ### Get Access Token

If you need the Facebook access token (for example, for validating the login on server side), do:
```js
var fbLoginSuccess = function (userData) {
console.log("UserInfo: ", userData);
facebookConnectPlugin.getAccessToken(function(token) {
console.log("Token: " + token);
});
}
var fbLoginSuccess = function (userData) {
alert("UserInfo: " + JSON.stringify(userData));
facebookConnectPlugin.getAccessToken(function(token) {
alert("Token: " + token);
}, function(err) {
alert("Could not get access token: " + err);
});
}
facebookConnectPlugin.login(["public_profile"], fbLoginSuccess,
function (error) {
console.error(error)
}
);
```
facebookConnectPlugin.login(["public_profile"],
fbLoginSuccess,
function (error) { alert("" + error) }
);
### Get Status and Post-to-wall

@@ -210,19 +218,16 @@

var fbLoginSuccess = function (userData) {
alert("UserInfo: " + JSON.stringify(userData));
facebookConnectPlugin.getLoginStatus(
function (status) {
alert("current status: " + JSON.stringify(status));
```js
var fbLoginSuccess = function (userData) {
console.log("UserInfo: ", userData);
facebookConnectPlugin.getLoginStatus(function onLoginStatus (status) {
console.log("current status: ", status);
facebookConnectPlugin.showDialog({
method: "share"
}, function onShareSuccess (result) {
console.log("Posted. ", result);
});
});
};
```
var options = { method:"feed" };
facebookConnectPlugin.showDialog(options,
function (result) {
alert("Posted. " + JSON.stringify(result)); },
function (e) {
alert("Failed: " + e);
});
}
);
};
### Getting a User's Birthday

@@ -232,15 +237,17 @@

facebookConnectPlugin.api("<user-id>/?fields=id,email", ["user_birthday"],
function (result) {
alert("Result: " + JSON.stringify(result));
/* alerts:
{
"id": "000000123456789",
"email": "myemail@example.com"
}
*/
},
function (error) {
alert("Failed: " + error);
});
```js
facebookConnectPlugin.api("<user-id>/?fields=id,email", ["user_birthday"],
function onSuccess (result) {
console.log("Result: ", result);
/* logs:
{
"id": "000000123456789",
"email": "myemail@example.com"
}
*/
}, function onError (error) {
console.error("Failed: ", error);
}
);
```

@@ -251,14 +258,16 @@ ### Publish a Photo

```js
facebookConnectPlugin.showDialog({
method: "share",
picture:'https://www.google.co.jp/logos/doodles/2014/doodle-4-google-2014-japan-winner-5109465267306496.2-hp.png',
name:'Test Post',
message:'First photo post',
caption: 'Testing using phonegap plugin',
description: 'Posting photo using phonegap facebook plugin'
}, function (response) {
console.log(response)
}, function (response) {
console.log(response)
}
);
```
facebookConnectPlugin.showDialog(
{
method: "feed",
picture:'https://www.google.co.jp/logos/doodles/2014/doodle-4-google-2014-japan-winner-5109465267306496.2-hp.png',
name:'Test Post',
message:'First photo post',
caption: 'Testing using phonegap plugin',
description: 'Posting photo using phonegap facebook plugin'
},
function (response) { alert(JSON.stringify(response)) },
function (response) { alert(JSON.stringify(response)) });
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc