cordova-plugin-firebase-authentication 4.0.2 → 7.0.0
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 +527 -127
- package/package.json +14 -6
- package/plugin.xml +12 -11
- 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 +252 -0
- package/types/index.d.ts +7 -0
- package/www/FirebaseAuthentication.js +366 -106
package/README.md
CHANGED
|
@@ -5,212 +5,612 @@
|
|
|
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
|
+
**`Example`**
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
// below we use cordova-plugin-sign-in-with-apple to trigger Apple Login UI
|
|
282
|
+
cordova.plugins.SignInWithApple.signin({
|
|
283
|
+
requestedScopes: [0, 1]
|
|
284
|
+
}, function(res) {
|
|
285
|
+
cordova.plugins.firebase.auth.signInWithApple(res.identityToken).then(function() {
|
|
286
|
+
console.log("Firebase logged in with Apple");
|
|
287
|
+
}, function(err) {
|
|
288
|
+
console.error("Firebase login failed", err);
|
|
289
|
+
});
|
|
290
|
+
}, function(err) {
|
|
291
|
+
console.error("Apple signin failed", err);
|
|
87
292
|
});
|
|
88
293
|
```
|
|
89
|
-
### signInWithVerificationId(_verificationId_, _smsCode_)
|
|
90
|
-
Asynchronously signs in using verificationId and 6-digit SMS code.
|
|
91
294
|
|
|
92
|
-
|
|
93
|
-
cordova.plugins.firebase.auth.signInWithVerificationId("djgfioerjg34", "123456");
|
|
94
|
-
```
|
|
295
|
+
#### Parameters
|
|
95
296
|
|
|
297
|
+
| Name | Type | Description |
|
|
298
|
+
| :------ | :------ | :------ |
|
|
299
|
+
| `idToken` | `string` | Apple's ID token string |
|
|
300
|
+
| `rawNonce` | `string` | Apple's raw token string |
|
|
96
301
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
302
|
+
#### Returns
|
|
303
|
+
|
|
304
|
+
`Promise`<`void`\>
|
|
305
|
+
|
|
306
|
+
Callback when operation is completed
|
|
307
|
+
|
|
308
|
+
___
|
|
309
|
+
|
|
310
|
+
### signInWithCustomToken
|
|
311
|
+
|
|
312
|
+
**signInWithCustomToken**(`authToken`): `Promise`<`void`\>
|
|
313
|
+
|
|
314
|
+
You can integrate Firebase Authentication with a custom authentication system
|
|
315
|
+
by modifying your authentication server to produce custom signed tokens when
|
|
316
|
+
a user successfully signs in. Your app receives this token and uses it to
|
|
317
|
+
authenticate with Firebase.
|
|
318
|
+
|
|
319
|
+
**`See`**
|
|
320
|
+
|
|
321
|
+
- https://firebase.google.com/docs/auth/android/custom-auth
|
|
322
|
+
- https://firebase.google.com/docs/auth/ios/custom-auth
|
|
323
|
+
|
|
324
|
+
#### Parameters
|
|
325
|
+
|
|
326
|
+
| Name | Type | Description |
|
|
327
|
+
| :------ | :------ | :------ |
|
|
328
|
+
| `authToken` | `string` | Custom auth token |
|
|
329
|
+
|
|
330
|
+
#### Returns
|
|
331
|
+
|
|
332
|
+
`Promise`<`void`\>
|
|
333
|
+
|
|
334
|
+
Callback when operation is completed
|
|
335
|
+
|
|
336
|
+
___
|
|
337
|
+
|
|
338
|
+
### signInWithEmailAndPassword
|
|
339
|
+
|
|
340
|
+
**signInWithEmailAndPassword**(`email`, `password`): `Promise`<`void`\>
|
|
341
|
+
|
|
342
|
+
Triggers the Firebase Authentication backend to send a password-reset email
|
|
343
|
+
to the given email address, which must correspond to an existing user of your app.
|
|
344
|
+
|
|
345
|
+
**`Example`**
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
cordova.plugins.firebase.auth.signInWithEmailAndPassword("my@mail.com", "pa55w0rd");
|
|
101
349
|
```
|
|
102
350
|
|
|
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).
|
|
351
|
+
#### Parameters
|
|
105
352
|
|
|
106
|
-
|
|
107
|
-
|
|
353
|
+
| Name | Type | Description |
|
|
354
|
+
| :------ | :------ | :------ |
|
|
355
|
+
| `email` | `string` | User account email |
|
|
356
|
+
| `password` | `string` | User accound password |
|
|
357
|
+
|
|
358
|
+
#### Returns
|
|
359
|
+
|
|
360
|
+
`Promise`<`void`\>
|
|
361
|
+
|
|
362
|
+
Callback when operation is completed
|
|
363
|
+
|
|
364
|
+
___
|
|
365
|
+
|
|
366
|
+
### signInWithFacebook
|
|
367
|
+
|
|
368
|
+
**signInWithFacebook**(`accessToken`): `Promise`<`void`\>
|
|
369
|
+
|
|
370
|
+
Uses Facebook's <code>accessToken</code> to sign-in into firebase account. In order to
|
|
371
|
+
retrieve those tokens follow instructions for iOS and Android from Firebase docs.
|
|
372
|
+
|
|
373
|
+
**`See`**
|
|
374
|
+
|
|
375
|
+
- https://firebase.google.com/docs/auth/android/facebook-login
|
|
376
|
+
- https://firebase.google.com/docs/auth/ios/facebook-login
|
|
377
|
+
|
|
378
|
+
#### Parameters
|
|
379
|
+
|
|
380
|
+
| Name | Type | Description |
|
|
381
|
+
| :------ | :------ | :------ |
|
|
382
|
+
| `accessToken` | `string` | Facebook's access token string |
|
|
383
|
+
|
|
384
|
+
#### Returns
|
|
385
|
+
|
|
386
|
+
`Promise`<`void`\>
|
|
387
|
+
|
|
388
|
+
Callback when operation is completed
|
|
389
|
+
|
|
390
|
+
___
|
|
391
|
+
|
|
392
|
+
### signInWithGoogle
|
|
393
|
+
|
|
394
|
+
**signInWithGoogle**(`idToken`, `accessToken`): `Promise`<`void`\>
|
|
108
395
|
|
|
109
|
-
|
|
396
|
+
Uses Google's <code>idToken</code> and <code>accessToken</code> to sign-in into firebase account.
|
|
110
397
|
|
|
111
|
-
|
|
398
|
+
**`Example`**
|
|
399
|
+
|
|
400
|
+
```ts
|
|
401
|
+
// Below we use cordova-plugin-googleplus to trigger Google Login UI
|
|
112
402
|
window.plugins.googleplus.login({
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
403
|
+
scopes: '... ',
|
|
404
|
+
webClientId: '1234...',
|
|
405
|
+
offline: true
|
|
116
406
|
}, function(res) {
|
|
117
|
-
// signin into Firebase
|
|
118
407
|
cordova.plugins.firebase.auth.signInWithGoogle(res.idToken, res.accessToken).then(function() {
|
|
119
408
|
console.log("Firebase logged in with Google");
|
|
409
|
+
}, function(err) {
|
|
410
|
+
console.error("Firebase login failed", err);
|
|
120
411
|
});
|
|
121
412
|
}, function(err) {
|
|
122
|
-
console.error("login failed", err);
|
|
413
|
+
console.error("Google login failed", err);
|
|
123
414
|
});
|
|
124
415
|
```
|
|
125
416
|
|
|
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).
|
|
417
|
+
#### Parameters
|
|
128
418
|
|
|
129
|
-
|
|
130
|
-
|
|
419
|
+
| Name | Type | Description |
|
|
420
|
+
| :------ | :------ | :------ |
|
|
421
|
+
| `idToken` | `string` | Google ID token |
|
|
422
|
+
| `accessToken` | `string` | Google Access token |
|
|
131
423
|
|
|
132
|
-
|
|
424
|
+
#### Returns
|
|
133
425
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
426
|
+
`Promise`<`void`\>
|
|
427
|
+
|
|
428
|
+
Callback when operation is completed
|
|
429
|
+
|
|
430
|
+
___
|
|
431
|
+
|
|
432
|
+
### signInWithTwitter
|
|
433
|
+
|
|
434
|
+
**signInWithTwitter**(`token`, `secret`): `Promise`<`void`\>
|
|
435
|
+
|
|
436
|
+
Uses Twitter's <code>token</code> and <code>secret</code> to sign-in into firebase account.
|
|
437
|
+
In order to retrieve those tokens follow instructions for iOS and Android from Firebase docs.
|
|
438
|
+
|
|
439
|
+
**`See`**
|
|
440
|
+
|
|
441
|
+
- https://firebase.google.com/docs/auth/android/twitter-login
|
|
442
|
+
- https://firebase.google.com/docs/auth/ios/twitter-login
|
|
443
|
+
|
|
444
|
+
#### Parameters
|
|
445
|
+
|
|
446
|
+
| Name | Type | Description |
|
|
447
|
+
| :------ | :------ | :------ |
|
|
448
|
+
| `token` | `string` | Twitter's token string |
|
|
449
|
+
| `secret` | `string` | Twitter's secret string |
|
|
450
|
+
|
|
451
|
+
#### Returns
|
|
452
|
+
|
|
453
|
+
`Promise`<`void`\>
|
|
454
|
+
|
|
455
|
+
Callback when operation is completed
|
|
456
|
+
|
|
457
|
+
___
|
|
458
|
+
|
|
459
|
+
### signInWithVerificationId
|
|
460
|
+
|
|
461
|
+
**signInWithVerificationId**(`verificationId`, `code`): `Promise`<`void`\>
|
|
462
|
+
|
|
463
|
+
Completes phone number verification process and use it to sign in.
|
|
464
|
+
|
|
465
|
+
**`Example`**
|
|
466
|
+
|
|
467
|
+
```ts
|
|
468
|
+
cordova.plugins.firebase.auth.verifyPhoneNumber("+123456789").then(function(verificationId) {
|
|
469
|
+
var code = prompt("Enter verification code");
|
|
470
|
+
if (code) {
|
|
471
|
+
return cordova.plugins.firebase.auth.signInWithVerificationId(verificationId, code);
|
|
472
|
+
}
|
|
473
|
+
}).catch(function(err) {
|
|
474
|
+
console.error("Phone number verification failed", err);
|
|
143
475
|
});
|
|
144
476
|
```
|
|
145
477
|
|
|
146
|
-
|
|
147
|
-
Uses Facebook's _accessToken_ to sign-in into firebase account. In order to retriave those tokens follow instructions for [Android](https://firebase.google.com/docs/auth/android/facebook-login) and [iOS](https://firebase.google.com/docs/auth/ios/facebook-login).
|
|
478
|
+
#### Parameters
|
|
148
479
|
|
|
149
|
-
|
|
150
|
-
|
|
480
|
+
| Name | Type | Description |
|
|
481
|
+
| :------ | :------ | :------ |
|
|
482
|
+
| `verificationId` | `string` | [description] |
|
|
483
|
+
| `code` | `string` | 6-digit SMS code |
|
|
151
484
|
|
|
152
|
-
|
|
153
|
-
|
|
485
|
+
#### Returns
|
|
486
|
+
|
|
487
|
+
`Promise`<`void`\>
|
|
488
|
+
|
|
489
|
+
Callback when operation is completed
|
|
490
|
+
|
|
491
|
+
___
|
|
492
|
+
|
|
493
|
+
### signOut
|
|
494
|
+
|
|
495
|
+
**signOut**(): `Promise`<`void`\>
|
|
154
496
|
|
|
155
|
-
### signOut()
|
|
156
497
|
Signs out the current user and clears it from the disk cache.
|
|
157
|
-
|
|
498
|
+
|
|
499
|
+
**`Example`**
|
|
500
|
+
|
|
501
|
+
```ts
|
|
158
502
|
cordova.plugins.firebase.auth.signOut();
|
|
159
503
|
```
|
|
160
504
|
|
|
161
|
-
|
|
162
|
-
Every method call returns a promise which is optionally fulfilled with an appropriate value.
|
|
505
|
+
#### Returns
|
|
163
506
|
|
|
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
|
-
```
|
|
507
|
+
`Promise`<`void`\>
|
|
171
508
|
|
|
172
|
-
|
|
173
|
-
|
|
509
|
+
Callback when operation is completed
|
|
510
|
+
|
|
511
|
+
___
|
|
512
|
+
|
|
513
|
+
### updateProfile
|
|
174
514
|
|
|
515
|
+
**updateProfile**(`profileDetails`): `Promise`<`void`\>
|
|
516
|
+
|
|
517
|
+
Updates the current user's profile data.
|
|
175
518
|
Passing a `null` value will delete the current attribute's value, but not
|
|
176
519
|
passing a property won't change the current attribute's value.
|
|
177
520
|
|
|
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
|
-
});
|
|
521
|
+
**`Example`**
|
|
185
522
|
|
|
186
|
-
|
|
523
|
+
```ts
|
|
187
524
|
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");
|
|
525
|
+
displayName: "Jane Q. User",
|
|
526
|
+
photoURL: "https://example.com/jane-q-user/profile.jpg",
|
|
193
527
|
});
|
|
194
528
|
```
|
|
195
529
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
530
|
+
#### Parameters
|
|
531
|
+
|
|
532
|
+
| Name | Type | Description |
|
|
533
|
+
| :------ | :------ | :------ |
|
|
534
|
+
| `profileDetails` | `Object` | User attributes. |
|
|
535
|
+
| `profileDetails.displayName` | `string` | - |
|
|
536
|
+
| `profileDetails.photoURL` | `string` | - |
|
|
537
|
+
|
|
538
|
+
#### Returns
|
|
539
|
+
|
|
540
|
+
`Promise`<`void`\>
|
|
541
|
+
|
|
542
|
+
Callback when operation is completed
|
|
543
|
+
|
|
544
|
+
___
|
|
545
|
+
|
|
546
|
+
### useAppLanguage
|
|
547
|
+
|
|
548
|
+
**useAppLanguage**(): `Promise`<`void`\>
|
|
549
|
+
|
|
550
|
+
Sets languageCode to the app’s current language.
|
|
551
|
+
|
|
552
|
+
**`Example`**
|
|
553
|
+
|
|
554
|
+
```ts
|
|
555
|
+
cordova.plugins.firebase.auth.useAppLanguage();
|
|
202
556
|
```
|
|
203
557
|
|
|
204
|
-
|
|
205
|
-
|
|
558
|
+
#### Returns
|
|
559
|
+
|
|
560
|
+
`Promise`<`void`\>
|
|
561
|
+
|
|
562
|
+
Callback when operation is completed
|
|
563
|
+
|
|
564
|
+
___
|
|
565
|
+
|
|
566
|
+
### useEmulator
|
|
567
|
+
|
|
568
|
+
**useEmulator**(`host`, `port`): `Promise`<`void`\>
|
|
206
569
|
|
|
207
|
-
### useAppLanguage()
|
|
208
570
|
Sets languageCode to the app’s current language.
|
|
209
571
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
572
|
+
**`Example`**
|
|
573
|
+
|
|
574
|
+
```ts
|
|
575
|
+
cordova.plugins.firebase.auth.useEmulator('localhost', 8000);
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
#### Parameters
|
|
579
|
+
|
|
580
|
+
| Name | Type | Description |
|
|
581
|
+
| :------ | :------ | :------ |
|
|
582
|
+
| `host` | `string` | Emulator host name |
|
|
583
|
+
| `port` | `number` | Emulator port |
|
|
584
|
+
|
|
585
|
+
#### Returns
|
|
586
|
+
|
|
587
|
+
`Promise`<`void`\>
|
|
588
|
+
|
|
589
|
+
Callback when operation is completed
|
|
590
|
+
|
|
591
|
+
___
|
|
592
|
+
|
|
593
|
+
### verifyPhoneNumber
|
|
594
|
+
|
|
595
|
+
**verifyPhoneNumber**(`phoneNumber`, `timeoutMillis?`): `Promise`<`string`\>
|
|
596
|
+
|
|
597
|
+
Starts the phone number verification process for the given phone number.
|
|
598
|
+
|
|
599
|
+
Android supports auto-verify and instant device verification.
|
|
600
|
+
<b>You must register `onAuthStateChanged` to get callback on instant verification.</b>
|
|
601
|
+
|
|
602
|
+
Maximum allowed value for timeout is 2 minutes. Use 0 to disable SMS-auto-retrieval.
|
|
603
|
+
If you specify a positive value less than 30 seconds, library will default to 30 seconds.
|
|
604
|
+
|
|
605
|
+
#### Parameters
|
|
606
|
+
|
|
607
|
+
| Name | Type | Description |
|
|
608
|
+
| :------ | :------ | :------ |
|
|
609
|
+
| `phoneNumber` | `string` | Phone number in international format |
|
|
610
|
+
| `timeoutMillis?` | `number` | Maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library. |
|
|
611
|
+
|
|
612
|
+
#### Returns
|
|
613
|
+
|
|
614
|
+
`Promise`<`string`\>
|
|
615
|
+
|
|
616
|
+
Fulfills promise with <code>verificationId</code> to use later for signing in
|