Facebook Login
@capacitor-community/facebook-login
Capacitor community plugin for native Facebook Login.
Maintainers
Maintainer | GitHub | Social | Sponsoring Company |
---|---|---|---|
Masahiko Sakakibara | rdlabo | @rdlabo | RELATION DESIGN LABO, GENERAL INC. ASSOCIATION |
Stewan Silva | stewones | @stewones | Intenseloop Inc. |
✨
Contributors
Made with contributors-img.
Demo
Dependency version
If you want to know facebook library version, you should check:
Installation
If you use capacitor 4:
% npm i --save @capacitor-community/facebook-login@next
% npx cap update
capacitor 3:
% npm i --save @capacitor-community/facebook-login
% npx cap update
Android configuration
In file android/app/src/main/java/**/**/MainActivity.java
, add the plugin to the initialization list:
import android.os.Bundle; // required for onCreate parameter
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(
com.getcapacitor.community.facebooklogin.FacebookLogin.class
);
}
}
In file android/app/src/main/AndroidManifest.xml
, add the following XML elements under <manifest><application>
:
In file android/app/src/main/res/values/strings.xml
add the following lines :
Don’t forget to replace [APP_ID]
and [CLIENT_TOKEN]
by your Facebook application Id.
More information can be found here: https://developers.facebook.com/docs/android/getting-started
If you have trouble.
Please restart Android Studio, and do clean build.
iOS configuration
In file ios/App/App/AppDelegate.swift
add or replace the following:
Add the following in the ios/App/App/info.plist
file inside of the outermost <dict>
:
More information can be found here: https://developers.facebook.com/docs/facebook-login/ios
Web configuration
import { FacebookLogin } from '@capacitor-community/facebook-login';
// use hook after platform dom ready
await FacebookLogin.initialize({ appId: '105890006170720' });
More information can be found here: https://developers.facebook.com/docs/facebook-login/web
And you must confirm return type at https://github.com/rdlabo/capacitor-facebook-login/blob/master/src/web.ts#L55-L57
not same type for default web facebook login!
Example
Login
Logout
import { FacebookLogin } from '@capacitor-community/facebook-login';
await FacebookLogin.logout();
CurrentAccessToken
getProfile
API
initialize(...)
login(...)
logout()
reauthorize()
getCurrentAccessToken()
getProfile(...)
- Interfaces
- Type Aliases
initialize(…)
Param | Type |
---|---|
options |
Partial<FacebookConfiguration> |
login(…)
Param | Type |
---|---|
options |
{ permissions: string[]; } |
Returns: Promise<FacebookLoginResponse>
logout()
reauthorize()
Returns: Promise<FacebookLoginResponse>
getCurrentAccessToken()
Returns: Promise<FacebookCurrentAccessTokenResponse>
getProfile(…)
Param | Type |
---|---|
options |
{ fields: readonly string[]; } |
Returns: Promise<T>
Interfaces
FacebookConfiguration
Prop | Type |
---|---|
appId |
string |
autoLogAppEvents |
boolean |
xfbml |
boolean |
version |
string |
locale |
string |
FacebookLoginResponse
Prop | Type |
---|---|
accessToken |
AccessToken | null |
recentlyGrantedPermissions |
string[] |
recentlyDeniedPermissions |
string[] |
AccessToken
Prop | Type |
---|---|
applicationId |
string |
declinedPermissions |
string[] |
expires |
string |
isExpired |
boolean |
lastRefresh |
string |
permissions |
string[] |
token |
string |
userId |
string |
FacebookCurrentAccessTokenResponse
Prop | Type |
---|---|
accessToken |
AccessToken | null |
Type Aliases
Partial
Make all properties in T optional
{
[P in keyof T]?: T[P];
}