Skip to content

Commit 111e90f

Browse files
authored
feat(facebook): update facebook SDK to 13.1.0 (#264)
1 parent 9b598b5 commit 111e90f

File tree

8 files changed

+1688
-2266
lines changed

8 files changed

+1688
-2266
lines changed

packages/facebook/index.android.ts

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ILoginManager } from './common';
22
import { AndroidActivityResultEventData, AndroidApplication, Application } from '@nativescript/core';
33

4-
function setToArray<T>(value: java.util.Set<T>, type: "string" | "number" | "boolean"): T[] {
4+
function setToArray<T>(value: java.util.Set<T>, type: 'string' | 'number' | 'boolean'): T[] {
55
const result = [];
66
const count = value.size();
77
const nativeObjects = value.toArray();
@@ -68,7 +68,7 @@ export class AccessToken {
6868

6969
get declinedPermissions() {
7070
if (!this.#declinedPermissions) {
71-
this.#declinedPermissions = setToArray(this.native.getDeclinedPermissions(), "string");
71+
this.#declinedPermissions = setToArray(this.native.getDeclinedPermissions(), 'string');
7272
}
7373
return this.#declinedPermissions;
7474
}
@@ -83,7 +83,7 @@ export class AccessToken {
8383

8484
get expiredPermissions(): string[] {
8585
if (!this.#expiredPermissions) {
86-
this.#expiredPermissions = setToArray(this.native.getExpiredPermissions(), "string");
86+
this.#expiredPermissions = setToArray(this.native.getExpiredPermissions(), 'string');
8787
}
8888
return this.#expiredPermissions;
8989
}
@@ -94,7 +94,7 @@ export class AccessToken {
9494

9595
get permissions(): string[] {
9696
if (!this.#permissions) {
97-
this.#permissions = setToArray(this.native.getPermissions(), "string");
97+
this.#permissions = setToArray(this.native.getPermissions(), 'string');
9898
}
9999
return this.#permissions;
100100
}
@@ -119,7 +119,6 @@ export class AccessToken {
119119
return com.facebook.AccessToken.isCurrentAccessTokenActive();
120120
}
121121

122-
123122
toJSON() {
124123
return {
125124
appID: this.appID,
@@ -133,8 +132,8 @@ export class AccessToken {
133132
permissions: this.permissions,
134133
refreshDate: this.refreshDate,
135134
tokenString: this.tokenString,
136-
userID: this.userID
137-
}
135+
userID: this.userID,
136+
};
138137
}
139138

140139
get native() {
@@ -172,7 +171,7 @@ export class LoginResult {
172171
return [];
173172
}
174173
if (!this.#declinedPermissions) {
175-
this.#declinedPermissions = setToArray(this.native.getRecentlyDeniedPermissions(), "string");
174+
this.#declinedPermissions = setToArray(this.native.getRecentlyDeniedPermissions(), 'string');
176175
}
177176
return this.#declinedPermissions;
178177
}
@@ -182,7 +181,7 @@ export class LoginResult {
182181
return [];
183182
}
184183
if (!this.#grantedPermissions) {
185-
this.#grantedPermissions = setToArray(this.native.getRecentlyGrantedPermissions(), "string");
184+
this.#grantedPermissions = setToArray(this.native.getRecentlyGrantedPermissions(), 'string');
186185
}
187186
return this.#grantedPermissions;
188187
}
@@ -206,8 +205,8 @@ export class LoginResult {
206205
declinedPermissions: this.declinedPermissions,
207206
grantedPermissions: this.grantedPermissions,
208207
isCancelled: this.isCancelled,
209-
token: this.token
210-
}
208+
token: this.token,
209+
};
211210
}
212211

213212
get native() {
@@ -222,13 +221,20 @@ export class LoginResult {
222221
export class LoginManager implements ILoginManager {
223222
static #native: com.facebook.login.LoginManager;
224223
static #callbackManager: com.facebook.CallbackManager;
224+
private static ensureNative() {
225+
if (!LoginManager.#native) {
226+
LoginManager.#native = com.facebook.login.LoginManager.getInstance();
227+
}
228+
}
225229

226-
static init() { }
230+
static init() {
231+
LoginManager.ensureNative();
232+
}
227233

228234
static logInWithPermissions(permissions: string[], context?: any): Promise<LoginResult> {
229235
return new Promise((resolve, reject) => {
230-
if (!this.#native) {
231-
this.#native = com.facebook.login.LoginManager.getInstance();
236+
LoginManager.ensureNative();
237+
if (!this.#callbackManager) {
232238
this.#callbackManager = com.facebook.CallbackManager.Factory.create();
233239
Application.android.on(AndroidApplication.activityResultEvent, (data: AndroidActivityResultEventData) => {
234240
this.#callbackManager.onActivityResult(data.requestCode, data.resultCode, data.intent);
@@ -253,6 +259,7 @@ export class LoginManager implements ILoginManager {
253259
}
254260

255261
static logout() {
262+
LoginManager.ensureNative();
256263
this.#native.logOut();
257264
}
258265
}

packages/facebook/platforms/android/include.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ repositories {
33
}
44

55
dependencies {
6-
implementation 'com.facebook.android:facebook-core:12.0.0'
7-
implementation 'com.facebook.android:facebook-login:12.0.0'
6+
implementation 'com.facebook.android:facebook-core:13.1.0'
7+
implementation 'com.facebook.android:facebook-login:13.1.0'
88
}
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pod 'FBSDKCoreKit', '~> 12.0.2'
2-
pod 'FBSDKLoginKit', '~> 12.0.2'
3-
pod 'GoogleUtilities', '~> 7.5'
1+
pod 'FBSDKCoreKit', '~> 13.1.0'
2+
pod 'FBSDKLoginKit', '~> 13.1.0'
3+
pod 'GoogleUtilities', '~> 7.7'

0 commit comments

Comments
 (0)