@capacitor-community/facebook-login
Advanced tools
Comparing version 3.2.0 to 3.3.0
@@ -9,2 +9,21 @@ { | ||
{ | ||
"name": "initialize", | ||
"signature": "(options: Partial<FacebookConfiguration>) => Promise<void>", | ||
"parameters": [ | ||
{ | ||
"name": "options", | ||
"docs": "", | ||
"type": "Partial<FacebookConfiguration>" | ||
} | ||
], | ||
"returns": "Promise<void>", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [ | ||
"Partial", | ||
"FacebookConfiguration" | ||
], | ||
"slug": "initialize" | ||
}, | ||
{ | ||
"name": "login", | ||
@@ -72,2 +91,46 @@ "signature": "(options: { permissions: string[]; }) => Promise<FacebookLoginResponse>", | ||
{ | ||
"name": "FacebookConfiguration", | ||
"slug": "facebookconfiguration", | ||
"docs": "", | ||
"tags": [], | ||
"methods": [], | ||
"properties": [ | ||
{ | ||
"name": "appId", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "autoLogAppEvents", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "xfbml", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "version", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "locale", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "string" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "FacebookLoginResponse", | ||
@@ -189,4 +252,19 @@ "slug": "facebookloginresponse", | ||
"enums": [], | ||
"typeAliases": [], | ||
"typeAliases": [ | ||
{ | ||
"name": "Partial", | ||
"slug": "partial", | ||
"docs": "Make all properties in T optional", | ||
"types": [ | ||
{ | ||
"text": "{\r\n [P in keyof T]?: T[P];\r\n}", | ||
"complexTypes": [ | ||
"T", | ||
"P" | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"pluginConfigs": [] | ||
} |
@@ -20,2 +20,3 @@ export interface AccessToken { | ||
export interface FacebookLoginPlugin { | ||
initialize(options: Partial<FacebookConfiguration>): Promise<void>; | ||
login(options: { | ||
@@ -48,1 +49,8 @@ permissions: string[]; | ||
} | ||
export interface FacebookConfiguration { | ||
appId: string; | ||
autoLogAppEvents: boolean; | ||
xfbml: boolean; | ||
version: string; | ||
locale: string; | ||
} |
import { WebPlugin } from '@capacitor/core'; | ||
import { FacebookLoginPlugin, FacebookLoginResponse, FacebookCurrentAccessTokenResponse } from './definitions'; | ||
import { FacebookLoginPlugin, FacebookLoginResponse, FacebookCurrentAccessTokenResponse, FacebookConfiguration } from './definitions'; | ||
declare global { | ||
@@ -10,2 +10,4 @@ interface Window { | ||
constructor(); | ||
initialize(options: Partial<FacebookConfiguration>): Promise<void>; | ||
private loadScript; | ||
login(options: { | ||
@@ -12,0 +14,0 @@ permissions: string[]; |
@@ -9,2 +9,36 @@ import { WebPlugin } from '@capacitor/core'; | ||
} | ||
initialize(options) { | ||
const defaultOptions = { version: 'v10.0' }; | ||
return new Promise((resolve, reject) => { | ||
try { | ||
return this.loadScript(options.locale).then(() => { | ||
FB.init(Object.assign(Object.assign({}, defaultOptions), options)); | ||
resolve(); | ||
}); | ||
} | ||
catch (err) { | ||
reject(err); | ||
} | ||
}); | ||
} | ||
loadScript(locale) { | ||
if (typeof document === 'undefined') { | ||
return Promise.resolve(); | ||
} | ||
const scriptId = 'fb'; | ||
const scriptEl = document === null || document === void 0 ? void 0 : document.getElementById(scriptId); | ||
if (scriptEl) { | ||
return Promise.resolve(); | ||
} | ||
const head = document.getElementsByTagName('head')[0]; | ||
const script = document.createElement('script'); | ||
return new Promise((resolve) => { | ||
script.defer = true; | ||
script.async = true; | ||
script.id = scriptId; | ||
script.onload = () => { resolve(); }; | ||
script.src = `https://connect.facebook.net/${locale !== null && locale !== void 0 ? locale : 'en_US'}/sdk.js`; | ||
head.appendChild(script); | ||
}); | ||
} | ||
async login(options) { | ||
@@ -11,0 +45,0 @@ console.log('FacebookLoginWeb.login', options); |
@@ -18,2 +18,36 @@ 'use strict'; | ||
} | ||
initialize(options) { | ||
const defaultOptions = { version: 'v10.0' }; | ||
return new Promise((resolve, reject) => { | ||
try { | ||
return this.loadScript(options.locale).then(() => { | ||
FB.init(Object.assign(Object.assign({}, defaultOptions), options)); | ||
resolve(); | ||
}); | ||
} | ||
catch (err) { | ||
reject(err); | ||
} | ||
}); | ||
} | ||
loadScript(locale) { | ||
if (typeof document === 'undefined') { | ||
return Promise.resolve(); | ||
} | ||
const scriptId = 'fb'; | ||
const scriptEl = document === null || document === void 0 ? void 0 : document.getElementById(scriptId); | ||
if (scriptEl) { | ||
return Promise.resolve(); | ||
} | ||
const head = document.getElementsByTagName('head')[0]; | ||
const script = document.createElement('script'); | ||
return new Promise((resolve) => { | ||
script.defer = true; | ||
script.async = true; | ||
script.id = scriptId; | ||
script.onload = () => { resolve(); }; | ||
script.src = `https://connect.facebook.net/${locale !== null && locale !== void 0 ? locale : 'en_US'}/sdk.js`; | ||
head.appendChild(script); | ||
}); | ||
} | ||
async login(options) { | ||
@@ -20,0 +54,0 @@ console.log('FacebookLoginWeb.login', options); |
@@ -15,2 +15,36 @@ var FacebookLoginPlugin = (function (exports, core) { | ||
} | ||
initialize(options) { | ||
const defaultOptions = { version: 'v10.0' }; | ||
return new Promise((resolve, reject) => { | ||
try { | ||
return this.loadScript(options.locale).then(() => { | ||
FB.init(Object.assign(Object.assign({}, defaultOptions), options)); | ||
resolve(); | ||
}); | ||
} | ||
catch (err) { | ||
reject(err); | ||
} | ||
}); | ||
} | ||
loadScript(locale) { | ||
if (typeof document === 'undefined') { | ||
return Promise.resolve(); | ||
} | ||
const scriptId = 'fb'; | ||
const scriptEl = document === null || document === void 0 ? void 0 : document.getElementById(scriptId); | ||
if (scriptEl) { | ||
return Promise.resolve(); | ||
} | ||
const head = document.getElementsByTagName('head')[0]; | ||
const script = document.createElement('script'); | ||
return new Promise((resolve) => { | ||
script.defer = true; | ||
script.async = true; | ||
script.id = scriptId; | ||
script.onload = () => { resolve(); }; | ||
script.src = `https://connect.facebook.net/${locale !== null && locale !== void 0 ? locale : 'en_US'}/sdk.js`; | ||
head.appendChild(script); | ||
}); | ||
} | ||
async login(options) { | ||
@@ -17,0 +51,0 @@ console.log('FacebookLoginWeb.login', options); |
{ | ||
"name": "@capacitor-community/facebook-login", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "A native plugin for Facebook Login", | ||
@@ -43,6 +43,6 @@ "main": "dist/plugin.cjs.js", | ||
"devDependencies": { | ||
"@capacitor/android": "3.0.0", | ||
"@capacitor/cli": "3.0.0", | ||
"@capacitor/android": "^3.0.0", | ||
"@capacitor/cli": "^3.0.0", | ||
"@capacitor/docgen": "^0.0.16", | ||
"@capacitor/ios": "3.0.0", | ||
"@capacitor/ios": "^3.0.0", | ||
"@ionic/eslint-config": "^0.3.0", | ||
@@ -49,0 +49,0 @@ "@ionic/prettier-config": "^1.0.1", |
@@ -9,3 +9,3 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p> | ||
<p align="center"> | ||
<img src="https://img.shields.io/maintenance/yes/2021?style=flat-square" /> | ||
<img src="https://img.shields.io/maintenance/yes/2022?style=flat-square" /> | ||
<!-- <a href="https://github.com/capacitor-community/example/actions?query=workflow%3A%22CI%22"><img src="https://img.shields.io/github/workflow/status/capacitor-community/example/CI?style=flat-square" /></a> --> | ||
@@ -164,20 +164,7 @@ <a href="https://www.npmjs.com/package/@capacitor-community/facebook-login"><img src="https://img.shields.io/npm/l/@capacitor-community/facebook-login?style=flat-square" /></a> | ||
```javascript | ||
window.fbAsyncInit = function() { | ||
FB.init({ | ||
appId: '[APP_ID]', | ||
cookie: true, // enable cookies to allow the server to access the session | ||
xfbml: true, // parse social plugins on this page | ||
version: 'v5.0' // use graph api current version | ||
}); | ||
}; | ||
```typescript | ||
import {FacebookLogin} from "@capacitor-community/facebook-login"; | ||
// Load the SDK asynchronously | ||
(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 = "https://connect.facebook.net/en_US/sdk.js"; | ||
fjs.parentNode.insertBefore(js, fjs); | ||
}(document, 'script', 'facebook-jssdk')); | ||
// use hook after platform dom ready | ||
await FacebookLogin.initialize({appId: '105890006170720'}); | ||
``` | ||
@@ -241,2 +228,3 @@ | ||
* [`initialize(...)`](#initialize) | ||
* [`login(...)`](#login) | ||
@@ -247,2 +235,3 @@ * [`logout()`](#logout) | ||
* [Interfaces](#interfaces) | ||
* [Type Aliases](#type-aliases) | ||
@@ -254,2 +243,15 @@ </docgen-index> | ||
### initialize(...) | ||
```typescript | ||
initialize(options: Partial<FacebookConfiguration>) => Promise<void> | ||
``` | ||
| Param | Type | | ||
| ------------- | ------------------------------------------------------------------------------------------------------------- | | ||
| **`options`** | <code><a href="#partial">Partial</a><<a href="#facebookconfiguration">FacebookConfiguration</a>></code> | | ||
-------------------- | ||
### login(...) | ||
@@ -308,2 +310,13 @@ | ||
#### FacebookConfiguration | ||
| Prop | Type | | ||
| ---------------------- | -------------------- | | ||
| **`appId`** | <code>string</code> | | ||
| **`autoLogAppEvents`** | <code>boolean</code> | | ||
| **`xfbml`** | <code>boolean</code> | | ||
| **`version`** | <code>string</code> | | ||
| **`locale`** | <code>string</code> | | ||
#### FacebookLoginResponse | ||
@@ -338,2 +351,12 @@ | ||
### Type Aliases | ||
#### Partial | ||
Make all properties in T optional | ||
<code>{ [P in keyof T]?: T[P]; }</code> | ||
</docgen-api> |
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
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
74526
705
356