2.2.0 • Published 1 year ago

@nativescript/facebook v2.2.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@nativescript/facebook

Installation

npm install @nativescript/facebook

Prerequisites

Android

Before you can run the project, follow the Getting Started Guide for Facebook Android SDK to set up a Facebook app. You can skip the build.gradle changes since that's taken care of by the rnpm link step above, but make sure you follow the rest of the steps such as updating strings.xml and AndroidManifest.xml.

iOS

Follow step 3 in the Getting Started Guide for Facebook SDK for iOS.

Usage

First of all, you should initialize the LoginManager by calling the init method.

import { LoginManager } from '@nativescript/facebook';

LoginManager.init() 

Then to log the user in, use the logInWithPermissions method. You can also use the Login Manager with custom UI to perform Login.

import { LoginManager, AccessToken } from '@nativescript/facebook';

try {
	const result = await LoginManager.logInWithPermissions(['public_profile']); // LoginResult
	const accessToken = AccessToken.currentAccessToken();
} catch (e) {}

To log the user out, call the logOut method.

LoginManager.logOut()

API

AccessToken

NameTypeDescription
appIDstring
dataAccessExpirationDateDatereadonly
dataAccessExpiredbooleanreadonly
declinedPermissionsstring[]readonly
expirationDateDatereadonly
expiredbooleanreadonly
expiredPermissionsstring[]readonly
graphDomainstringreadonly
permissionsstring[]readonly
refreshDateDatereadonly
tokenStringstringreadonly
userIDstringreadonly
currentAccessToken()AccessTokenA static method that returns an access token.
currentAccessTokenIsActivebooleanreadonly
iosFBSDKAccessTokenreadonly. iOS access token.
androidAccessTokenreadonly. Android access token.

LoginResult Class

NameTypeDescription
androidLoginManagerreadonly. Native instance for Android.
iosFBSDKLoginManagerreadonly. Native instance for iOS.
grantedPermissionsstring[]readonly
isCancelledbooleanreadonly
tokenAccessTokenreadonly

LoginManager Class

NameType/Return TypeDescription
static init()voidInitializes the LoginManager. You should call this method early in the app lifecycle and the best place for that is the main.ts.
static logInWithPermissions(permissions: string[], context?: any)Promise<LoginResult>Opens the login window in the optionally provided context(a UIViewController instance on iOS and an Activity(https://developer.android.The permissions parameter indicates the data about the user the app would like to get from Facebook.
static logout()voidLogs out the user.

License

Apache License Version 2.0

2.2.0

1 year ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.3

2 years ago

2.1.1-alpha.0

2 years ago

2.1.0-alpha.0

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago

1.0.0-alpha.5

2 years ago

1.0.0-alpha.4

3 years ago

1.0.0-alpha.3

3 years ago

1.0.0-alpha.2

3 years ago

1.0.0-alpha.1

3 years ago

1.0.0-alpha.0

3 years ago