Skip to content

Commit 1b4f53f

Browse files
authored
chore(facebook): README improved (#448)
1 parent 6a22eae commit 1b4f53f

File tree

1 file changed

+101
-9
lines changed

1 file changed

+101
-9
lines changed

packages/facebook/README.md

+101-9
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,63 @@
11
# @nativescript/facebook
22

3+
## Contents
4+
* [Intro](#intro)
5+
* [Installation](#installation)
6+
* [Android prerequisites](#android-prerequisites)
7+
* [iOS prerequisites](#ios-prerequisites)
8+
* [Use @nativescript/facebook](#use-nativescriptfacebook)
9+
* [Sign in the user](#sign-in-the-user)
10+
* [Sign out the user](#sign-out-the-user)
11+
* [API](#api)
12+
* [LoginManager class](#loginmanager-class)
13+
* [LoginResult class](#loginresult-class)
14+
* [AccessToken class](#accesstoken-class)
15+
* [Properties](#properties)
16+
* [Methods](#methods)
17+
18+
## Intro
19+
20+
A plugin that allows you to integrate Facebook Login with your app using the Facebook SDK.
21+
322
## Installation
23+
24+
Install the plugin to add the Facebook SDK by running the following command:
25+
426
```cli
527
npm install @nativescript/facebook
628
```
729

8-
## Prerequisites
30+
## Android prerequisites
31+
32+
Set up your app to use the Facebook SDK for Android by following the instructions under the following sections in [Getting Started Guide](https://developers.facebook.com/docs/android/getting-started/).
933

10-
### Android
34+
- [Get Your App ID](https://developers.facebook.com/docs/android/getting-started#app-id)
35+
- [Get Your Client Token](https://developers.facebook.com/docs/android/getting-started#client-token)
36+
- [Update Your Manifest](https://developers.facebook.com/docs/android/getting-started/#add-app_id)
1137

12-
Before you can run the project, follow the [Getting Started Guide](https://developers.facebook.com/docs/android/getting-started/) 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`.
38+
## iOS prerequisites
1339

14-
### iOS
40+
Set up your app to use the Facebook SDK for iOS by following the instructions in the following sections on [Getting Started Guide](https://developers.facebook.com/docs/ios/getting-started#getting-started-with-the-facebook-sdk-for-ios):
1541

16-
Follow step 3 in the [Getting Started Guide](https://developers.facebook.com/docs/ios/use-cocoapods) for Facebook SDK for iOS.
42+
- [Before You Start](https://developers.facebook.com/docs/ios/getting-started#before-you-start)
43+
- [Get Your App ID](https://developers.facebook.com/docs/ios/getting-started#app-id)
44+
- [Get Your Client Token](https://developers.facebook.com/docs/ios/getting-started#client-token)
45+
- [Step 2: Configure Your Project](https://developers.facebook.com/docs/ios/getting-started#configure-your-project)
1746

18-
## Usage
19-
First of all, you should initialize the LoginManager by calling the `init` method.
47+
## Use @nativescript/facebook
48+
49+
### Sign in the user
50+
51+
Firstly, initialize the LoginManager by calling the `init` method.
2052

2153
```ts
2254
import { LoginManager } from '@nativescript/facebook';
2355

2456
LoginManager.init()
2557
```
26-
Then to log the user in, use the `logInWithPermissions` method.
27-
You can also use the Login Manager with custom UI to perform Login.
58+
Next, to sign the user in, call the `logInWithPermissions` method.
59+
<!-- You can also use the Login Manager with custom UI to perform Login. -->
60+
<!-- How? 👆🏼 -->
2861

2962
```ts
3063
import { LoginManager, AccessToken } from '@nativescript/facebook';
@@ -34,6 +67,65 @@ try {
3467
const accessToken = AccessToken.currentAccessToken();
3568
} catch (e) {}
3669
```
70+
### Sign out the user
71+
72+
To log the user out, call the `logOut` method.
73+
```ts
74+
LoginManager.logOut()
75+
```
76+
77+
## API
78+
79+
### LoginManager class
80+
81+
The LoginManager class provides the following static methods:
82+
83+
| Method | Returns | Description |
84+
|------|------|-------------|
85+
| `static init()`| `void` | Initializes the LoginManager. Call this method early in the app lifecycle and the best place for that is the `main.ts` file.|
86+
| `static logInWithPermissions(permissions: string[], context?: any)` | Promise<[LoginResult](#loginresult-class)>| Opens the login window in the optionally provided `context`(a [UIViewController](https://developer.apple.com/documentation/uikit/uiviewcontroller?language=objc) 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. |
87+
| `static logout()` | `void`| Logs out the user. |
88+
89+
### LoginResult class
90+
This class provides the login data returned by the `logInWithPermissions` method.
91+
92+
| Name | Type | Description |
93+
|------|------|-------------|
94+
| `android` | [LoginManager](https://developers.facebook.com/docs/reference/android/current/class/LoginManager/) |_readonly_. Native instance for Android. |
95+
| ` ios` |[FBSDKLoginManager](https://developers.facebook.com/docs/reference/ios/current/class/FBSDKLoginManager/)|_readonly_. Native instance for iOS.|
96+
| `grantedPermissions`|`string[]`| _readonly_|
97+
| `isCancelled`|`boolean`| _readonly_|
98+
| `token`| [AccessToken](#accesstoken)| _readonly_|
99+
100+
### AccessToken class
101+
102+
This class provides the data of a Facebook access token.
103+
104+
#### Properties
105+
106+
| Property | Type| Description |
107+
|------|-----|-------------|
108+
| `appID` | `string`||
109+
| `dataAccessExpirationDate` | `Date`|_readonly_|
110+
| `dataAccessExpired` | `boolean` | _readonly_|
111+
| `declinedPermissions`|`string[]`| _readonly_|
112+
| `expirationDate`| `Date`| _readonly_|
113+
| `expired`| `boolean`| _readonly_|
114+
| `expiredPermissions`|`string[]`| _readonly_|
115+
| `graphDomain` | `string` | _readonly_|
116+
| `permissions`|`string[]`| _readonly_|
117+
| `refreshDate`| `Date`| _readonly_|
118+
| `tokenString` | `string`| _readonly_|
119+
| `userID` | `string`| _readonly_|
120+
| `currentAccessTokenIsActive` | `boolean` | _readonly_|
121+
| `ios` | [FBSDKAccessToken](https://developers.facebook.com/docs/reference/ios/current/class/FBSDKAccessToken/)|_readonly_. iOS access token. |
122+
| `android` | [AccessToken](https://developers.facebook.com/docs/reference/android/current/class/AccessToken/)|_readonly_. Android access token. |
123+
124+
#### Methods
125+
126+
| Method | Returns
127+
|:------|:-------
128+
| `currentAccessToken()` | [AccessToken](#accesstoken-class) | A static method that returns an access token as an instance of the AccessToken class.|
37129

38130
To log the user out, call the `logOut` method.
39131
```ts

0 commit comments

Comments
 (0)