cordova-plugin-firebase-authentication 5.0.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +537 -127
- package/package.json +15 -6
- package/plugin.xml +10 -9
- package/src/android/FirebaseAuthenticationPlugin.java +82 -95
- package/src/ios/FirebaseAuthenticationPlugin.h +1 -1
- package/src/ios/FirebaseAuthenticationPlugin.m +2 -0
- package/tsconfig.json +15 -0
- package/types/FirebaseAuthentication.d.ts +258 -0
- package/types/index.d.ts +7 -0
- package/www/FirebaseAuthentication.js +372 -106
package/README.md
CHANGED
|
@@ -5,212 +5,622 @@
|
|
|
5
5
|
| [][donate-url] | Your help is appreciated. Create a PR, submit a bug or just grab me :beer: |
|
|
6
6
|
|-|-|
|
|
7
7
|
|
|
8
|
+
[npm-url]: https://www.npmjs.com/package/cordova-plugin-firebase-authentication
|
|
9
|
+
[npm-version]: https://img.shields.io/npm/v/cordova-plugin-firebase-authentication.svg
|
|
10
|
+
[npm-downloads]: https://img.shields.io/npm/dm/cordova-plugin-firebase-authentication.svg
|
|
11
|
+
[npm-total-downloads]: https://img.shields.io/npm/dt/cordova-plugin-firebase-authentication.svg?label=total+downloads
|
|
12
|
+
[twitter-url]: https://twitter.com/chemerisuk
|
|
13
|
+
[twitter-follow]: https://img.shields.io/twitter/follow/chemerisuk.svg?style=social&label=Follow%20me
|
|
14
|
+
[donate-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FYAALBP25DP2G&source=url
|
|
15
|
+
|
|
8
16
|
## Index
|
|
9
17
|
|
|
10
|
-
<!-- MarkdownTOC levels="2" autolink="true" -->
|
|
18
|
+
<!-- MarkdownTOC levels="2,3" autolink="true" -->
|
|
11
19
|
|
|
12
|
-
- [Installation](#installation)
|
|
13
20
|
- [Supported Platforms](#supported-platforms)
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
21
|
+
- [Installation](#installation)
|
|
22
|
+
- [Adding required configuration files](#adding-required-configuration-files)
|
|
23
|
+
- [Type Aliases](#type-aliases)
|
|
24
|
+
- [UserDetails](#userdetails)
|
|
25
|
+
- [Functions](#functions)
|
|
26
|
+
- [createUserWithEmailAndPassword](#createuserwithemailandpassword)
|
|
27
|
+
- [getCurrentUser](#getcurrentuser)
|
|
28
|
+
- [getIdToken](#getidtoken)
|
|
29
|
+
- [onAuthStateChanged](#onauthstatechanged)
|
|
30
|
+
- [sendEmailVerification](#sendemailverification)
|
|
31
|
+
- [sendPasswordResetEmail](#sendpasswordresetemail)
|
|
32
|
+
- [signInAnonymously](#signinanonymously)
|
|
33
|
+
- [signInWithApple](#signinwithapple)
|
|
34
|
+
- [signInWithCustomToken](#signinwithcustomtoken)
|
|
35
|
+
- [signInWithEmailAndPassword](#signinwithemailandpassword)
|
|
36
|
+
- [signInWithFacebook](#signinwithfacebook)
|
|
37
|
+
- [signInWithGoogle](#signinwithgoogle)
|
|
38
|
+
- [signInWithTwitter](#signinwithtwitter)
|
|
39
|
+
- [signInWithVerificationId](#signinwithverificationid)
|
|
40
|
+
- [signOut](#signout)
|
|
41
|
+
- [updateProfile](#updateprofile)
|
|
42
|
+
- [useAppLanguage](#useapplanguage)
|
|
43
|
+
- [useEmulator](#useemulator)
|
|
44
|
+
- [verifyPhoneNumber](#verifyphonenumber)
|
|
16
45
|
|
|
17
46
|
<!-- /MarkdownTOC -->
|
|
18
47
|
|
|
48
|
+
## Supported Platforms
|
|
49
|
+
|
|
50
|
+
- iOS
|
|
51
|
+
- Android
|
|
52
|
+
|
|
19
53
|
## Installation
|
|
20
54
|
|
|
21
55
|
cordova plugin add cordova-plugin-firebase-authentication
|
|
22
56
|
|
|
23
|
-
Use variables `
|
|
57
|
+
Use variables `IOS_FIREBASE_POD_VERSION` and `ANDROID_FIREBASE_BOM_VERSION` to override dependency versions for Firebase SDKs:
|
|
58
|
+
|
|
59
|
+
$ cordova plugin add cordova-plugin-firebase-authentication \
|
|
60
|
+
--variable IOS_FIREBASE_POD_VERSION="9.3.0" \
|
|
61
|
+
--variable ANDROID_FIREBASE_BOM_VERSION="30.3.1"
|
|
24
62
|
|
|
25
63
|
To use phone number authentication on iOS, your app must be able to receive silent APNs notifications from Firebase. For iOS 8.0 and above silent notifications do not require explicit user consent and is therefore unaffected by a user declining to receive APNs notifications in the app. Thus, the app does not need to request user permission to receive push notifications when implementing Firebase phone number auth.
|
|
26
64
|
|
|
27
|
-
|
|
65
|
+
### Adding required configuration files
|
|
28
66
|
|
|
29
|
-
- iOS
|
|
30
|
-
- Android
|
|
67
|
+
Cordova supports `resource-file` tag for easy copying resources files. Firebase SDK requires `google-services.json` on Android and `GoogleService-Info.plist` on iOS platforms.
|
|
31
68
|
|
|
32
|
-
|
|
33
|
-
|
|
69
|
+
1. Put `google-services.json` and/or `GoogleService-Info.plist` into the root directory of your Cordova project
|
|
70
|
+
2. Add new tag for Android platform
|
|
34
71
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} else {
|
|
46
|
-
// user was signed out
|
|
47
|
-
}
|
|
48
|
-
});
|
|
72
|
+
```xml
|
|
73
|
+
<platform name="android">
|
|
74
|
+
...
|
|
75
|
+
<resource-file src="google-services.json" target="app/google-services.json" />
|
|
76
|
+
</platform>
|
|
77
|
+
...
|
|
78
|
+
<platform name="ios">
|
|
79
|
+
...
|
|
80
|
+
<resource-file src="GoogleService-Info.plist" />
|
|
81
|
+
</platform>
|
|
49
82
|
```
|
|
50
83
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
84
|
+
<!-- TypedocGenerated -->
|
|
85
|
+
|
|
86
|
+
## Type Aliases
|
|
87
|
+
|
|
88
|
+
### UserDetails
|
|
89
|
+
|
|
90
|
+
**UserDetails**: `Object`
|
|
91
|
+
|
|
92
|
+
Represents a user's profile information in your Firebase project's user database.
|
|
93
|
+
|
|
94
|
+
#### Type declaration
|
|
95
|
+
|
|
96
|
+
| Name | Type | Description |
|
|
97
|
+
| :------ | :------ | :------ |
|
|
98
|
+
| `displayName` | `string` | Main display name of this user from the Firebase project's user database |
|
|
99
|
+
| `email` | `string` | Main email address of the user, as stored in the Firebase project's user database. |
|
|
100
|
+
| `emailVerified` | `boolean` | <code>true</code> if the user's email is verified. |
|
|
101
|
+
| `phoneNumber` | `string` \| ``null`` | Phone number of the user, as stored in the Firebase project's user database, or null if none exists. |
|
|
102
|
+
| `photoURL` | `string` | URL of this user's main profile picture, as stored in the Firebase project's user database. |
|
|
103
|
+
| `providerId` | `string` | - |
|
|
104
|
+
| `uid` | `string` | String used to uniquely identify your user in your Firebase project's user database |
|
|
105
|
+
|
|
106
|
+
## Functions
|
|
107
|
+
|
|
108
|
+
### createUserWithEmailAndPassword
|
|
109
|
+
|
|
110
|
+
**createUserWithEmailAndPassword**(`email`, `password`): `Promise`<`void`\>
|
|
111
|
+
|
|
112
|
+
Creates a new user account with the given email address and password.
|
|
113
|
+
|
|
114
|
+
**`Example`**
|
|
115
|
+
|
|
116
|
+
```ts
|
|
54
117
|
cordova.plugins.firebase.auth.createUserWithEmailAndPassword("my@mail.com", "pa55w0rd");
|
|
55
118
|
```
|
|
56
119
|
|
|
57
|
-
|
|
120
|
+
#### Parameters
|
|
121
|
+
|
|
122
|
+
| Name | Type | Description |
|
|
123
|
+
| :------ | :------ | :------ |
|
|
124
|
+
| `email` | `string` | User account email |
|
|
125
|
+
| `password` | `string` | User accound password |
|
|
126
|
+
|
|
127
|
+
#### Returns
|
|
128
|
+
|
|
129
|
+
`Promise`<`void`\>
|
|
130
|
+
|
|
131
|
+
Callback when operation is completed
|
|
132
|
+
|
|
133
|
+
___
|
|
134
|
+
|
|
135
|
+
### getCurrentUser
|
|
136
|
+
|
|
137
|
+
**getCurrentUser**(): `Promise`<[`UserDetails`](#userdetails)\>
|
|
138
|
+
|
|
139
|
+
Returns the current user in the Firebase instance.
|
|
140
|
+
|
|
141
|
+
#### Returns
|
|
142
|
+
|
|
143
|
+
`Promise`<[`UserDetails`](#userdetails)\>
|
|
144
|
+
|
|
145
|
+
Fulfills promise with user details
|
|
146
|
+
|
|
147
|
+
___
|
|
148
|
+
|
|
149
|
+
### getIdToken
|
|
150
|
+
|
|
151
|
+
**getIdToken**(`forceRefresh`): `Promise`<`string`\>
|
|
152
|
+
|
|
153
|
+
Returns a JWT token used to identify the user to a Firebase service.
|
|
154
|
+
|
|
155
|
+
**`Example`**
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
cordova.plugins.firebase.auth.getIdToken().then(function(idToken) {
|
|
159
|
+
// send token to server
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Parameters
|
|
164
|
+
|
|
165
|
+
| Name | Type | Description |
|
|
166
|
+
| :------ | :------ | :------ |
|
|
167
|
+
| `forceRefresh` | `boolean` | When <code>true</code> cached value is ignored |
|
|
168
|
+
|
|
169
|
+
#### Returns
|
|
170
|
+
|
|
171
|
+
`Promise`<`string`\>
|
|
172
|
+
|
|
173
|
+
Fulfills promis with id token string value
|
|
174
|
+
|
|
175
|
+
___
|
|
176
|
+
|
|
177
|
+
### onAuthStateChanged
|
|
178
|
+
|
|
179
|
+
**onAuthStateChanged**(`callback`, `errorCallback?`): () => `void`
|
|
180
|
+
|
|
181
|
+
Registers a block as an auth state did change listener. To be invoked when:
|
|
182
|
+
- The block is registered as a listener,
|
|
183
|
+
- A user with a different UID from the current user has signed in, or
|
|
184
|
+
- The current user has signed out.
|
|
185
|
+
|
|
186
|
+
#### Parameters
|
|
187
|
+
|
|
188
|
+
| Name | Type | Description |
|
|
189
|
+
| :------ | :------ | :------ |
|
|
190
|
+
| `callback` | (`userDetails`: [`UserDetails`](#userdetails)) => `void` | Callback function |
|
|
191
|
+
| `errorCallback?` | (`error`: `string`) => `void` | Error callback function |
|
|
192
|
+
|
|
193
|
+
#### Returns
|
|
194
|
+
|
|
195
|
+
`fn`
|
|
196
|
+
|
|
197
|
+
(): `void`
|
|
198
|
+
|
|
199
|
+
##### Returns
|
|
200
|
+
|
|
201
|
+
`void`
|
|
202
|
+
|
|
203
|
+
___
|
|
204
|
+
|
|
205
|
+
### sendEmailVerification
|
|
206
|
+
|
|
207
|
+
**sendEmailVerification**(): `Promise`<`void`\>
|
|
208
|
+
|
|
58
209
|
Initiates email verification for the current user.
|
|
59
|
-
|
|
210
|
+
|
|
211
|
+
**`Example`**
|
|
212
|
+
|
|
213
|
+
```ts
|
|
60
214
|
cordova.plugins.firebase.auth.sendEmailVerification();
|
|
61
215
|
```
|
|
62
216
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
217
|
+
#### Returns
|
|
218
|
+
|
|
219
|
+
`Promise`<`void`\>
|
|
220
|
+
|
|
221
|
+
Callback when operation is completed
|
|
222
|
+
|
|
223
|
+
___
|
|
224
|
+
|
|
225
|
+
### sendPasswordResetEmail
|
|
226
|
+
|
|
227
|
+
**sendPasswordResetEmail**(`email`): `Promise`<`void`\>
|
|
228
|
+
|
|
229
|
+
Triggers the Firebase Authentication backend to send a password-reset email
|
|
230
|
+
to the given email address, which must correspond to an existing user of your app.
|
|
231
|
+
|
|
232
|
+
**`Example`**
|
|
233
|
+
|
|
234
|
+
```ts
|
|
66
235
|
cordova.plugins.firebase.auth.sendPasswordResetEmail("my@mail.com");
|
|
67
236
|
```
|
|
68
237
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
238
|
+
#### Parameters
|
|
239
|
+
|
|
240
|
+
| Name | Type | Description |
|
|
241
|
+
| :------ | :------ | :------ |
|
|
242
|
+
| `email` | `string` | User account email |
|
|
243
|
+
|
|
244
|
+
#### Returns
|
|
245
|
+
|
|
246
|
+
`Promise`<`void`\>
|
|
247
|
+
|
|
248
|
+
Callback when operation is completed
|
|
249
|
+
|
|
250
|
+
___
|
|
251
|
+
|
|
252
|
+
### signInAnonymously
|
|
253
|
+
|
|
254
|
+
**signInAnonymously**(): `Promise`<`void`\>
|
|
255
|
+
|
|
256
|
+
Create and use temporary anonymous account to authenticate with Firebase.
|
|
257
|
+
|
|
258
|
+
**`Example`**
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
cordova.plugins.firebase.auth.signInAnonymously();
|
|
73
262
|
```
|
|
74
263
|
|
|
75
|
-
|
|
76
|
-
Starts the phone number verification process for the given phone number.
|
|
264
|
+
#### Returns
|
|
77
265
|
|
|
78
|
-
|
|
266
|
+
`Promise`<`void`\>
|
|
79
267
|
|
|
80
|
-
|
|
268
|
+
Callback when operation is completed
|
|
81
269
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
270
|
+
___
|
|
271
|
+
|
|
272
|
+
### signInWithApple
|
|
273
|
+
|
|
274
|
+
**signInWithApple**(`idToken`, `rawNonce`): `Promise`<`void`\>
|
|
275
|
+
|
|
276
|
+
Uses Apples's <code>idToken</code> and <code>rawNonce</code> to sign-in into firebase account. For getting _idToken_ (_rawNonce_ is optional) you can use `cordova-plugin-sign-in-with-apple` (or any other cordova plugin for Apple Sign-In).
|
|
277
|
+
|
|
278
|
+
**`See`**
|
|
279
|
+
|
|
280
|
+
- https://firebase.google.com/docs/auth/android/apple
|
|
281
|
+
- https://firebase.google.com/docs/auth/ios/apple
|
|
282
|
+
|
|
283
|
+
**`Example`**
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
// below we use cordova-plugin-sign-in-with-apple to trigger Apple Login UI
|
|
287
|
+
cordova.plugins.SignInWithApple.signin({
|
|
288
|
+
requestedScopes: [0, 1]
|
|
289
|
+
}, function(res) {
|
|
290
|
+
cordova.plugins.firebase.auth.signInWithApple(res.identityToken).then(function() {
|
|
291
|
+
console.log("Firebase logged in with Apple");
|
|
292
|
+
}, function(err) {
|
|
293
|
+
console.error("Firebase login failed", err);
|
|
294
|
+
});
|
|
295
|
+
}, function(err) {
|
|
296
|
+
console.error("Apple signin failed", err);
|
|
87
297
|
});
|
|
88
298
|
```
|
|
89
|
-
### signInWithVerificationId(_verificationId_, _smsCode_)
|
|
90
|
-
Asynchronously signs in using verificationId and 6-digit SMS code.
|
|
91
299
|
|
|
92
|
-
|
|
93
|
-
cordova.plugins.firebase.auth.signInWithVerificationId("djgfioerjg34", "123456");
|
|
94
|
-
```
|
|
300
|
+
#### Parameters
|
|
95
301
|
|
|
302
|
+
| Name | Type | Description |
|
|
303
|
+
| :------ | :------ | :------ |
|
|
304
|
+
| `idToken` | `string` | Apple's ID token string |
|
|
305
|
+
| `rawNonce` | `string` | Apple's raw token string |
|
|
96
306
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
307
|
+
#### Returns
|
|
308
|
+
|
|
309
|
+
`Promise`<`void`\>
|
|
310
|
+
|
|
311
|
+
Callback when operation is completed
|
|
312
|
+
|
|
313
|
+
___
|
|
314
|
+
|
|
315
|
+
### signInWithCustomToken
|
|
316
|
+
|
|
317
|
+
**signInWithCustomToken**(`authToken`): `Promise`<`void`\>
|
|
318
|
+
|
|
319
|
+
You can integrate Firebase Authentication with a custom authentication system
|
|
320
|
+
by modifying your authentication server to produce custom signed tokens when
|
|
321
|
+
a user successfully signs in. Your app receives this token and uses it to
|
|
322
|
+
authenticate with Firebase.
|
|
323
|
+
|
|
324
|
+
**`See`**
|
|
325
|
+
|
|
326
|
+
- https://firebase.google.com/docs/auth/android/custom-auth
|
|
327
|
+
- https://firebase.google.com/docs/auth/ios/custom-auth
|
|
328
|
+
|
|
329
|
+
#### Parameters
|
|
330
|
+
|
|
331
|
+
| Name | Type | Description |
|
|
332
|
+
| :------ | :------ | :------ |
|
|
333
|
+
| `authToken` | `string` | Custom auth token |
|
|
334
|
+
|
|
335
|
+
#### Returns
|
|
336
|
+
|
|
337
|
+
`Promise`<`void`\>
|
|
338
|
+
|
|
339
|
+
Callback when operation is completed
|
|
340
|
+
|
|
341
|
+
___
|
|
342
|
+
|
|
343
|
+
### signInWithEmailAndPassword
|
|
344
|
+
|
|
345
|
+
**signInWithEmailAndPassword**(`email`, `password`): `Promise`<`void`\>
|
|
346
|
+
|
|
347
|
+
Triggers the Firebase Authentication backend to send a password-reset email
|
|
348
|
+
to the given email address, which must correspond to an existing user of your app.
|
|
349
|
+
|
|
350
|
+
**`Example`**
|
|
351
|
+
|
|
352
|
+
```ts
|
|
353
|
+
cordova.plugins.firebase.auth.signInWithEmailAndPassword("my@mail.com", "pa55w0rd");
|
|
101
354
|
```
|
|
102
355
|
|
|
103
|
-
|
|
104
|
-
Uses Google's _idToken_ and _accessToken_ to sign-in into firebase account. In order to retriave those tokens you can use `cordova-plugin-googleplus` (or any other cordova plugin for Google Sign-In).
|
|
356
|
+
#### Parameters
|
|
105
357
|
|
|
106
|
-
|
|
107
|
-
|
|
358
|
+
| Name | Type | Description |
|
|
359
|
+
| :------ | :------ | :------ |
|
|
360
|
+
| `email` | `string` | User account email |
|
|
361
|
+
| `password` | `string` | User accound password |
|
|
362
|
+
|
|
363
|
+
#### Returns
|
|
364
|
+
|
|
365
|
+
`Promise`<`void`\>
|
|
366
|
+
|
|
367
|
+
Callback when operation is completed
|
|
368
|
+
|
|
369
|
+
___
|
|
370
|
+
|
|
371
|
+
### signInWithFacebook
|
|
372
|
+
|
|
373
|
+
**signInWithFacebook**(`accessToken`): `Promise`<`void`\>
|
|
374
|
+
|
|
375
|
+
Uses Facebook's <code>accessToken</code> to sign-in into firebase account. In order to
|
|
376
|
+
retrieve those tokens follow instructions for iOS and Android from Firebase docs.
|
|
377
|
+
|
|
378
|
+
**`See`**
|
|
379
|
+
|
|
380
|
+
- https://firebase.google.com/docs/auth/android/facebook-login
|
|
381
|
+
- https://firebase.google.com/docs/auth/ios/facebook-login
|
|
382
|
+
|
|
383
|
+
#### Parameters
|
|
384
|
+
|
|
385
|
+
| Name | Type | Description |
|
|
386
|
+
| :------ | :------ | :------ |
|
|
387
|
+
| `accessToken` | `string` | Facebook's access token string |
|
|
388
|
+
|
|
389
|
+
#### Returns
|
|
390
|
+
|
|
391
|
+
`Promise`<`void`\>
|
|
392
|
+
|
|
393
|
+
Callback when operation is completed
|
|
394
|
+
|
|
395
|
+
___
|
|
396
|
+
|
|
397
|
+
### signInWithGoogle
|
|
398
|
+
|
|
399
|
+
**signInWithGoogle**(`idToken`, `accessToken`): `Promise`<`void`\>
|
|
108
400
|
|
|
109
|
-
|
|
401
|
+
Uses Google's <code>idToken</code> and <code>accessToken</code> to sign-in into firebase account.
|
|
110
402
|
|
|
111
|
-
|
|
403
|
+
**`See`**
|
|
404
|
+
|
|
405
|
+
- https://firebase.google.com/docs/auth/android/google-signin
|
|
406
|
+
- https://firebase.google.com/docs/auth/ios/google-signin
|
|
407
|
+
|
|
408
|
+
**`Example`**
|
|
409
|
+
|
|
410
|
+
```ts
|
|
411
|
+
// Below we use cordova-plugin-googleplus to trigger Google Login UI
|
|
112
412
|
window.plugins.googleplus.login({
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
413
|
+
scopes: '... ',
|
|
414
|
+
webClientId: '1234...',
|
|
415
|
+
offline: true
|
|
116
416
|
}, function(res) {
|
|
117
|
-
// signin into Firebase
|
|
118
417
|
cordova.plugins.firebase.auth.signInWithGoogle(res.idToken, res.accessToken).then(function() {
|
|
119
418
|
console.log("Firebase logged in with Google");
|
|
419
|
+
}, function(err) {
|
|
420
|
+
console.error("Firebase login failed", err);
|
|
120
421
|
});
|
|
121
422
|
}, function(err) {
|
|
122
|
-
console.error("login failed", err);
|
|
423
|
+
console.error("Google login failed", err);
|
|
123
424
|
});
|
|
124
425
|
```
|
|
125
426
|
|
|
126
|
-
|
|
127
|
-
Uses Apples's _idToken_ and _rawNonce_ to sign-in into firebase account. For getting _idToken_ (_rawNonce_ is optional) you can use `cordova-plugin-sign-in-with-apple` (or any other cordova plugin for Apple Sign-In).
|
|
427
|
+
#### Parameters
|
|
128
428
|
|
|
129
|
-
|
|
130
|
-
|
|
429
|
+
| Name | Type | Description |
|
|
430
|
+
| :------ | :------ | :------ |
|
|
431
|
+
| `idToken` | `string` | Google ID token |
|
|
432
|
+
| `accessToken` | `string` | Google Access token |
|
|
131
433
|
|
|
132
|
-
|
|
434
|
+
#### Returns
|
|
133
435
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
436
|
+
`Promise`<`void`\>
|
|
437
|
+
|
|
438
|
+
Callback when operation is completed
|
|
439
|
+
|
|
440
|
+
___
|
|
441
|
+
|
|
442
|
+
### signInWithTwitter
|
|
443
|
+
|
|
444
|
+
**signInWithTwitter**(`token`, `secret`): `Promise`<`void`\>
|
|
445
|
+
|
|
446
|
+
Uses Twitter's <code>token</code> and <code>secret</code> to sign-in into firebase account.
|
|
447
|
+
In order to retrieve those tokens follow instructions for iOS and Android from Firebase docs.
|
|
448
|
+
|
|
449
|
+
**`See`**
|
|
450
|
+
|
|
451
|
+
- https://firebase.google.com/docs/auth/android/twitter-login
|
|
452
|
+
- https://firebase.google.com/docs/auth/ios/twitter-login
|
|
453
|
+
|
|
454
|
+
#### Parameters
|
|
455
|
+
|
|
456
|
+
| Name | Type | Description |
|
|
457
|
+
| :------ | :------ | :------ |
|
|
458
|
+
| `token` | `string` | Twitter's token string |
|
|
459
|
+
| `secret` | `string` | Twitter's secret string |
|
|
460
|
+
|
|
461
|
+
#### Returns
|
|
462
|
+
|
|
463
|
+
`Promise`<`void`\>
|
|
464
|
+
|
|
465
|
+
Callback when operation is completed
|
|
466
|
+
|
|
467
|
+
___
|
|
468
|
+
|
|
469
|
+
### signInWithVerificationId
|
|
470
|
+
|
|
471
|
+
**signInWithVerificationId**(`verificationId`, `code`): `Promise`<`void`\>
|
|
472
|
+
|
|
473
|
+
Completes phone number verification process and use it to sign in.
|
|
474
|
+
|
|
475
|
+
**`Example`**
|
|
476
|
+
|
|
477
|
+
```ts
|
|
478
|
+
cordova.plugins.firebase.auth.verifyPhoneNumber("+123456789").then(function(verificationId) {
|
|
479
|
+
var code = prompt("Enter verification code");
|
|
480
|
+
if (code) {
|
|
481
|
+
return cordova.plugins.firebase.auth.signInWithVerificationId(verificationId, code);
|
|
482
|
+
}
|
|
483
|
+
}).catch(function(err) {
|
|
484
|
+
console.error("Phone number verification failed", err);
|
|
143
485
|
});
|
|
144
486
|
```
|
|
145
487
|
|
|
146
|
-
|
|
147
|
-
|
|
488
|
+
#### Parameters
|
|
489
|
+
|
|
490
|
+
| Name | Type | Description |
|
|
491
|
+
| :------ | :------ | :------ |
|
|
492
|
+
| `verificationId` | `string` | [description] |
|
|
493
|
+
| `code` | `string` | 6-digit SMS code |
|
|
494
|
+
|
|
495
|
+
#### Returns
|
|
496
|
+
|
|
497
|
+
`Promise`<`void`\>
|
|
148
498
|
|
|
149
|
-
|
|
150
|
-
Uses Twitter's _token_ and _secret_ to sign-in into firebase account. In order to retriave those tokens follow instructions for [Android](https://firebase.google.com/docs/auth/android/twitter-login) and [iOS](https://firebase.google.com/docs/auth/ios/twitter-login).
|
|
499
|
+
Callback when operation is completed
|
|
151
500
|
|
|
152
|
-
|
|
153
|
-
|
|
501
|
+
___
|
|
502
|
+
|
|
503
|
+
### signOut
|
|
504
|
+
|
|
505
|
+
**signOut**(): `Promise`<`void`\>
|
|
154
506
|
|
|
155
|
-
### signOut()
|
|
156
507
|
Signs out the current user and clears it from the disk cache.
|
|
157
|
-
|
|
508
|
+
|
|
509
|
+
**`Example`**
|
|
510
|
+
|
|
511
|
+
```ts
|
|
158
512
|
cordova.plugins.firebase.auth.signOut();
|
|
159
513
|
```
|
|
160
514
|
|
|
161
|
-
|
|
162
|
-
Every method call returns a promise which is optionally fulfilled with an appropriate value.
|
|
515
|
+
#### Returns
|
|
163
516
|
|
|
164
|
-
|
|
165
|
-
Returns the current user in the Firebase instance.
|
|
166
|
-
```js
|
|
167
|
-
cordova.plugins.firebase.auth.getCurrentUser().then(function(userInfo) {
|
|
168
|
-
// user information or null if not logged in
|
|
169
|
-
})
|
|
170
|
-
```
|
|
517
|
+
`Promise`<`void`\>
|
|
171
518
|
|
|
172
|
-
|
|
173
|
-
|
|
519
|
+
Callback when operation is completed
|
|
520
|
+
|
|
521
|
+
___
|
|
174
522
|
|
|
523
|
+
### updateProfile
|
|
524
|
+
|
|
525
|
+
**updateProfile**(`profileDetails`): `Promise`<`void`\>
|
|
526
|
+
|
|
527
|
+
Updates the current user's profile data.
|
|
175
528
|
Passing a `null` value will delete the current attribute's value, but not
|
|
176
529
|
passing a property won't change the current attribute's value.
|
|
177
530
|
|
|
178
|
-
|
|
179
|
-
cordova.plugins.firebase.auth.updateProfile({
|
|
180
|
-
displayName: "Jane Q. User",
|
|
181
|
-
photoURL: "https://example.com/jane-q-user/profile.jpg"
|
|
182
|
-
}).then(function() {
|
|
183
|
-
console.log("user profile updated");
|
|
184
|
-
});
|
|
531
|
+
**`Example`**
|
|
185
532
|
|
|
186
|
-
|
|
533
|
+
```ts
|
|
187
534
|
cordova.plugins.firebase.auth.updateProfile({
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
// displayName is unchanged - "Jane Q. User"
|
|
191
|
-
// photoURL is changed - null
|
|
192
|
-
console.log("only photoURL is changed");
|
|
535
|
+
displayName: "Jane Q. User",
|
|
536
|
+
photoURL: "https://example.com/jane-q-user/profile.jpg",
|
|
193
537
|
});
|
|
194
538
|
```
|
|
195
539
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
540
|
+
#### Parameters
|
|
541
|
+
|
|
542
|
+
| Name | Type | Description |
|
|
543
|
+
| :------ | :------ | :------ |
|
|
544
|
+
| `profileDetails` | `Object` | User attributes. |
|
|
545
|
+
| `profileDetails.displayName` | `string` | - |
|
|
546
|
+
| `profileDetails.photoURL` | `string` | - |
|
|
547
|
+
|
|
548
|
+
#### Returns
|
|
549
|
+
|
|
550
|
+
`Promise`<`void`\>
|
|
551
|
+
|
|
552
|
+
Callback when operation is completed
|
|
553
|
+
|
|
554
|
+
___
|
|
555
|
+
|
|
556
|
+
### useAppLanguage
|
|
557
|
+
|
|
558
|
+
**useAppLanguage**(): `Promise`<`void`\>
|
|
559
|
+
|
|
560
|
+
Sets languageCode to the app’s current language.
|
|
561
|
+
|
|
562
|
+
**`Example`**
|
|
563
|
+
|
|
564
|
+
```ts
|
|
565
|
+
cordova.plugins.firebase.auth.useAppLanguage();
|
|
202
566
|
```
|
|
203
567
|
|
|
204
|
-
|
|
205
|
-
|
|
568
|
+
#### Returns
|
|
569
|
+
|
|
570
|
+
`Promise`<`void`\>
|
|
571
|
+
|
|
572
|
+
Callback when operation is completed
|
|
573
|
+
|
|
574
|
+
___
|
|
575
|
+
|
|
576
|
+
### useEmulator
|
|
577
|
+
|
|
578
|
+
**useEmulator**(`host`, `port`): `Promise`<`void`\>
|
|
206
579
|
|
|
207
|
-
### useAppLanguage()
|
|
208
580
|
Sets languageCode to the app’s current language.
|
|
209
581
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
582
|
+
**`Example`**
|
|
583
|
+
|
|
584
|
+
```ts
|
|
585
|
+
cordova.plugins.firebase.auth.useEmulator('localhost', 8000);
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
#### Parameters
|
|
589
|
+
|
|
590
|
+
| Name | Type | Description |
|
|
591
|
+
| :------ | :------ | :------ |
|
|
592
|
+
| `host` | `string` | Emulator host name |
|
|
593
|
+
| `port` | `number` | Emulator port |
|
|
594
|
+
|
|
595
|
+
#### Returns
|
|
596
|
+
|
|
597
|
+
`Promise`<`void`\>
|
|
598
|
+
|
|
599
|
+
Callback when operation is completed
|
|
600
|
+
|
|
601
|
+
___
|
|
602
|
+
|
|
603
|
+
### verifyPhoneNumber
|
|
604
|
+
|
|
605
|
+
**verifyPhoneNumber**(`phoneNumber`, `timeoutMillis?`): `Promise`<`string`\>
|
|
606
|
+
|
|
607
|
+
Starts the phone number verification process for the given phone number.
|
|
608
|
+
|
|
609
|
+
Android supports auto-verify and instant device verification.
|
|
610
|
+
<b>You must register `onAuthStateChanged` to get callback on instant verification.</b>
|
|
611
|
+
|
|
612
|
+
Maximum allowed value for timeout is 2 minutes. Use 0 to disable SMS-auto-retrieval.
|
|
613
|
+
If you specify a positive value less than 30 seconds, library will default to 30 seconds.
|
|
614
|
+
|
|
615
|
+
#### Parameters
|
|
616
|
+
|
|
617
|
+
| Name | Type | Description |
|
|
618
|
+
| :------ | :------ | :------ |
|
|
619
|
+
| `phoneNumber` | `string` | Phone number in international format |
|
|
620
|
+
| `timeoutMillis?` | `number` | Maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library. |
|
|
621
|
+
|
|
622
|
+
#### Returns
|
|
623
|
+
|
|
624
|
+
`Promise`<`string`\>
|
|
625
|
+
|
|
626
|
+
Fulfills promise with <code>verificationId</code> to use later for signing in
|