facebook-handshake
Seamlessly log into Facebook silently, with a popup or with a redirect on unsupported browsers (Chrome/iOS).
Install
npm install --save facebook-handshake
Usage
; // MUST be called before anything else to store the data for the login.FBH; // silent checkFBH // user clicks on connectButtonconnectButton FBH
Init with options
FBH;
Init with callback (via promise)
FBH;
Silent login check
The user won't see anything, so you can proceed to use their previously-requested login or call FBH.login()
whenever the user clicks on your [Login]
button.
FBH;
First-time login
The user will be presented with the standard Facebook login popup or will be redirected to the specified URL on Chrome/iOS.
// do this on click/tap or else the browser will block the popupFBH
Specify a scope
Only when logging in with a popup, specify the required scope this way:
FBH;
Force a scope change
If the user is already logged in and connected, calling .login()
with a different scope will not update. Use the second parameter (force
) to, well, force it to display the login window with the new scope request.
FBH;
Enable or disable the internal logging
;// it starts "off"loadFacebookAPIlogging;FBH;// [FB API] Ready// [FB] User login response: {id: '...', token: '...'}
Support multiple apps on multiple domains
Create multiple apps (or test version of apps) on Facebook, and then easily switch
between them:
To make this work across multiple ports, make sure you also specify the above domain in the "App Domains" field in your Facebook app (screenshot)
Build
The project is in ES6 but transformed into ES5 with rollup-babel-lib-bundler. To do that, run:
npm run build