1
+ // @ts -nocheck
1
2
import { AndroidApplication , Application , AndroidActivityResultEventData , Utils } from '@nativescript/core' ;
2
3
import { colorSchemeProperty , ColorSchemeType , colorStyleProperty , ColorStyleType , Configuration , GoogleSignInButtonBase , IUser } from './common' ;
3
4
import lazy from '@nativescript/core/utils/lazy' ;
@@ -13,7 +14,6 @@ const COLOR_DARK = lazy(() => com.google.android.gms.common.SignInButton.COLOR_D
13
14
const COLOR_LIGHT = lazy ( ( ) => com . google . android . gms . common . SignInButton . COLOR_LIGHT ) ;
14
15
const COLOR_AUTO = lazy ( ( ) => com . google . android . gms . common . SignInButton . COLOR_AUTO ) ;
15
16
16
-
17
17
export class GoogleError extends Error {
18
18
#native: java . lang . Exception ;
19
19
static fromNative ( native : java . lang . Exception , message ?: string ) {
@@ -27,13 +27,12 @@ export class GoogleError extends Error {
27
27
}
28
28
}
29
29
30
-
31
30
export class User implements IUser {
32
- #native: com . google . android . gms . auth . api . signin . GoogleSignInAccount ;
31
+ #native: com . google . android . gms . auth . api . identity . SignInCredential ;
33
32
#grantedScopes: string [ ] ;
34
33
#accessToken: string ;
35
- static fromNative ( account : com . google . android . gms . auth . api . signin . GoogleSignInAccount , accessToken : string = null ) {
36
- if ( account instanceof com . google . android . gms . auth . api . signin . GoogleSignInAccount ) {
34
+ static fromNative ( account : com . google . android . gms . auth . api . identity . SignInCredential , accessToken : string = null ) {
35
+ if ( account instanceof com . google . android . gms . auth . api . identity . SignInCredential ) {
37
36
const user = new User ( ) ;
38
37
user . #native = account ;
39
38
user . #accessToken = accessToken ;
@@ -51,7 +50,8 @@ export class User implements IUser {
51
50
}
52
51
53
52
get email ( ) {
54
- return this . native . getEmail ( ) ;
53
+ console . log ( 'request scope for access.' ) ;
54
+ return '' ;
55
55
}
56
56
57
57
get givenName ( ) {
@@ -63,7 +63,7 @@ export class User implements IUser {
63
63
}
64
64
65
65
get idToken ( ) {
66
- return this . native . getIdToken ( ) ;
66
+ return this . native . getGoogleIdToken ( ) ;
67
67
}
68
68
69
69
get accessToken ( ) {
@@ -72,16 +72,17 @@ export class User implements IUser {
72
72
73
73
get grantedScopes ( ) {
74
74
if ( ! this . #grantedScopes) {
75
- const grantedScopes = [ ] ;
76
- const scopes = this . native . getGrantedScopes ( ) . toArray ( ) ;
77
- const length = scopes . length ;
78
- for ( let i = 0 ; i < length ; i ++ ) {
79
- const scope = scopes [ i ] ?. toString ?.( ) ;
80
- if ( scope ) {
81
- grantedScopes . push ( scope ) ;
82
- }
83
- }
84
- this . #grantedScopes = grantedScopes ;
75
+ // removed.
76
+ // const grantedScopes = [];
77
+ // const scopes = this.native.getGrantedScopes().toArray();
78
+ // const length = scopes.length;
79
+ // for (let i = 0; i < length; i++) {
80
+ // const scope = scopes[i]?.toString?.();
81
+ // if (scope) {
82
+ // grantedScopes.push(scope);
83
+ // }
84
+ // }
85
+ // this.#grantedScopes = grantedScopes;
85
86
}
86
87
return this . #grantedScopes;
87
88
}
@@ -91,7 +92,7 @@ export class User implements IUser {
91
92
}
92
93
93
94
get serverAuthCode ( ) {
94
- return this . native . getServerAuthCode ( ) ;
95
+ // return this.native.getServerAuthCode();
95
96
}
96
97
97
98
requestScopes ( scopes : string [ ] ) : Promise < User > {
@@ -248,7 +249,7 @@ export class GoogleSignin {
248
249
static playServicesAvailable ( ) {
249
250
return new Promise ( ( resolve , reject ) => {
250
251
resolve ( org . nativescript . plugins . googlesignin . GoogleSignIn . playServicesAvailable ( false , Application . android . foregroundActivity || Application . android . startActivity ) ) ;
251
- } )
252
+ } ) ;
252
253
}
253
254
}
254
255
0 commit comments