cordova-plugin-facebook4
Advanced tools
Comparing version 1.7.2 to 1.7.3
@@ -31,14 +31,4 @@ # Facebook Requirements and Set-Up [Web App] | ||
- 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, 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 domain (or localhost for testing). | ||
![image](app_domain_setup.png) |
{ | ||
"name": "cordova-plugin-facebook4", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "Cordova Facebook SDK 4 Plugin", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -7,2 +7,4 @@ # cordova-plugin-facebook4 | ||
See npm package for versions - https://www.npmjs.com/package/cordova-plugin-facebook4 | ||
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). | ||
@@ -46,4 +48,2 @@ | ||
**NOTE** : Developers should call `facebookConnectPlugin.browserInit(<appId>)` before login - **Web App ONLY** (see [Web App Guide](docs/browser/README.md)) | ||
Success function returns an Object like: | ||
@@ -50,0 +50,0 @@ |
@@ -1,6 +0,13 @@ | ||
/* global FB */ | ||
var isInited = false | ||
/* globals */ | ||
var __fbSdkReady = false; | ||
var __fbCallbacks = []; | ||
/* */ | ||
exports.getLoginStatus = function getLoginStatus (s, f) { | ||
if (!assertInited()) return printError(f, new Error('init not called with valid version')) | ||
if (!__fbSdkReady) { | ||
return __fbCallbacks.push(function() { | ||
getLoginStatus(s, f); | ||
}); | ||
} | ||
FB.getLoginStatus(function (response) { | ||
@@ -12,3 +19,7 @@ s(response) | ||
exports.showDialog = function showDialog (options, s, f) { | ||
if (!assertInited()) return printError(f, new Error('init not called with valid version')) | ||
if (!__fbSdkReady) { | ||
return __fbCallbacks.push(function() { | ||
showDialog(options, s, f); | ||
}); | ||
} | ||
@@ -21,2 +32,3 @@ options.name = options.name || '' | ||
options.picture = options.picture || '' | ||
options.quote = options.quote || '' | ||
@@ -28,3 +40,3 @@ FB.ui(options, function (response) { | ||
} | ||
printError(f, response) | ||
f(response.message) | ||
}) | ||
@@ -34,3 +46,7 @@ } | ||
exports.login = function login (permissions, s, f) { | ||
if (!assertInited()) return printError(f, new Error('init not called with valid version')) | ||
if (!__fbSdkReady) { | ||
return __fbCallbacks.push(function() { | ||
login(permissions, s, f); | ||
}); | ||
} | ||
// JS SDK takes an object here but the native SDKs use array. | ||
@@ -51,3 +67,3 @@ var options = {} | ||
} else { | ||
printError(f, response.status) | ||
f(response.status.message) | ||
} | ||
@@ -63,3 +79,3 @@ }, options) | ||
} | ||
printError(f, new Error('NO_TOKEN')) | ||
f('NO_TOKEN') | ||
} | ||
@@ -72,3 +88,3 @@ | ||
exports.logPurchase = function (value, currency, s, f) { | ||
exports.logPurchase = function logPurchase (value, currency, s, f) { | ||
// AppEvents are not avaliable in JS. | ||
@@ -78,3 +94,3 @@ s() | ||
exports.appInvite = function (options, s, f) { | ||
exports.appInvite = function appInvite (options, s, f) { | ||
// App Invites are not avaliable in JS. | ||
@@ -84,4 +100,9 @@ s() | ||
exports.logout = function (s, f) { | ||
if (!assertInited()) return printError(f, new Error('init not called with valid version')) | ||
exports.logout = function logout (s, f) { | ||
if (!__fbSdkReady) { | ||
return __fbCallbacks.push(function() { | ||
logout(s, f); | ||
}); | ||
} | ||
FB.logout(function (response) { | ||
@@ -92,4 +113,9 @@ s(response) | ||
exports.api = function (graphPath, permissions, s, f) { | ||
if (!assertInited()) return printError(f, new Error('init not called with valid version')) | ||
exports.api = function api (graphPath, permissions, s, f) { | ||
if (!__fbSdkReady) { | ||
return __fbCallbacks.push(function() { | ||
api(graphPath, permissions, s, f); | ||
}); | ||
} | ||
// JS API does not take additional permissions | ||
@@ -105,53 +131,31 @@ FB.api(graphPath, function (response) { | ||
// Browser wrapper API ONLY | ||
exports.browserInit = function (appId, version, s) { | ||
if (s == null && typeof version === 'function') { | ||
s = version | ||
version = null | ||
} | ||
exports.browserInit = function browserInit (appId, version, s) { | ||
console.warn("browserInit is deprecated and may be removed in the future"); | ||
console.trace(); | ||
} | ||
// Global :( | ||
// This function will be called by the FB SDK when the client is inited | ||
window.fbAsyncInit = function fbAsyncInit () { | ||
version = version || 'v2.6' | ||
if (window.location.protocol === "file:") { | ||
console.warn("Facebook JS SDK is not supported when using file:// protocol"); | ||
} else { | ||
window.fbAsyncInit = function() { | ||
FB.init({ | ||
appId: appId, | ||
xfbml: false, | ||
version: version | ||
}) | ||
appId : APP_ID, // APP_ID is populated by the cordova after_prepare hook | ||
xfbml : true, | ||
version : 'v2.6' | ||
}); | ||
isInited = true | ||
__fbSdkReady = true; | ||
if (typeof s === 'function') s() | ||
} | ||
for (var i = 0; i < __fbCallbacks.length; i++) { | ||
__fbCallbacks[i](); | ||
} | ||
}; | ||
// Bake in the JS SDK | ||
insertSdk() | ||
(function(d, s, id){ | ||
var js, fjs = d.getElementsByTagName(s)[0]; | ||
if (d.getElementById(id)) {return;} | ||
js = d.createElement(s); js.id = id; | ||
js.src = "//connect.facebook.net/en_US/sdk.js"; | ||
fjs.parentNode.insertBefore(js, fjs); | ||
}(document, 'script', 'facebook-jssdk')); | ||
} | ||
function assertInited () { | ||
if (!isInited) { | ||
return false | ||
} | ||
return true | ||
} | ||
function printError (f, err) { | ||
if (typeof f === 'function') { | ||
f(err.message) | ||
return | ||
} | ||
console.error(err.stack) | ||
} | ||
function insertSdk () { | ||
var js | ||
var fjs = document.getElementsByTagName('script')[0] | ||
if (document.getElementById('facebook-jssdk')) return | ||
js = document.createElement('script') | ||
js.id = 'facebook-jssdk' | ||
js.src = 'https://connect.facebook.net/en_US/sdk.js' | ||
fjs.parentNode.insertBefore(js, fjs) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
48385718
122
563
1