@angular/fire 7.5.0 → 7.6.0-canary.7a2402a

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.
Files changed (57) hide show
  1. package/README.md +85 -70
  2. package/bundles/angular-fire.umd.js +1 -1
  3. package/bundles/angular-fire.umd.js.map +1 -1
  4. package/docs/analytics.md +67 -0
  5. package/docs/app-check.md +53 -0
  6. package/docs/auth.md +165 -0
  7. package/docs/{analytics → compat/analytics}/getting-started.md +2 -0
  8. package/docs/{auth → compat/auth}/getting-started.md +2 -0
  9. package/docs/{auth → compat/auth}/router-guards.md +2 -0
  10. package/docs/{emulators → compat/emulators}/emulators.md +2 -0
  11. package/docs/{firestore → compat/firestore}/collections.md +2 -0
  12. package/docs/{firestore → compat/firestore}/documents.md +2 -0
  13. package/docs/{firestore → compat/firestore}/offline-data.md +2 -0
  14. package/docs/{firestore → compat/firestore}/querying-collections.md +2 -0
  15. package/docs/{functions → compat/functions}/functions.md +2 -0
  16. package/docs/{messaging → compat/messaging}/messaging.md +2 -0
  17. package/docs/{performance → compat/performance}/getting-started.md +2 -0
  18. package/docs/{remote-config → compat/remote-config}/getting-started.md +2 -0
  19. package/docs/{rtdb → compat/rtdb}/lists.md +2 -0
  20. package/docs/{rtdb → compat/rtdb}/objects.md +2 -0
  21. package/docs/{rtdb → compat/rtdb}/querying-lists.md +2 -0
  22. package/docs/{storage → compat/storage}/storage.md +2 -0
  23. package/docs/compat.md +70 -0
  24. package/docs/database.md +175 -0
  25. package/docs/firestore.md +148 -0
  26. package/docs/functions.md +52 -0
  27. package/docs/images/analytics-illo_1x.png +0 -0
  28. package/docs/images/auth-illo_1x.png +0 -0
  29. package/docs/images/cloud-messaging-illo_1x.png +0 -0
  30. package/docs/images/database-illo_1x.png +0 -0
  31. package/docs/images/firestore-illo_1x.png +0 -0
  32. package/docs/images/functions-illo_1x.png +0 -0
  33. package/docs/images/hosting-illo_1x.png +0 -0
  34. package/docs/images/performance-illo_1x.png +0 -0
  35. package/docs/images/reCAPTCHA-logo@1x.png +0 -0
  36. package/docs/images/remote-config-illo_1x.png +0 -0
  37. package/docs/images/storage-illo_1x.png +0 -0
  38. package/docs/install-and-setup.md +38 -85
  39. package/docs/messaging.md +25 -0
  40. package/docs/performance.md +57 -0
  41. package/docs/remote-config.md +53 -0
  42. package/docs/storage.md +90 -0
  43. package/esm2015/core.js +1 -1
  44. package/fesm2015/angular-fire.js +1 -1
  45. package/fesm2015/angular-fire.js.map +1 -1
  46. package/package.json +8 -8
  47. package/schematics/deploy/actions.js +23 -14
  48. package/schematics/firebaseTools.js +4 -2
  49. package/schematics/setup/index.js +58 -29
  50. package/schematics/setup/prompts.js +18 -46
  51. package/schematics/utils.js +32 -28
  52. package/docs/ionic/authentication.md +0 -104
  53. package/docs/ionic/cli.md +0 -218
  54. package/docs/ionic/v2.md +0 -531
  55. package/docs/ionic/v3.md +0 -705
  56. package/schematics/setup/ssr.js +0 -100
  57. package/schematics/setup/static.js +0 -78
package/docs/ionic/v2.md DELETED
@@ -1,531 +0,0 @@
1
- # Using AngularFire with Ionic 2
2
-
3
- This document provides you a walkthrough of integrating AngularFire Authentication with Ionic2.
4
- The below setup has been tested on Windows 10, but it should be same for Mac/Linux.
5
-
6
- Ensure that you're executing these commands as **Administrator** on Windows and **sudo** on Mac/Linux to avoid any errors.
7
-
8
- ### Prerequisites
9
- The first step is to ensure you've latest version of **Node** installed.
10
- You can get the latest version from [here](https://nodejs.org).
11
- This will install both node and npm.
12
-
13
- After installing node, check the version by executing the following command in your prompt window.
14
-
15
- ```bash
16
-
17
- C:\projects>node -v
18
- v6.9.1
19
-
20
- ```
21
-
22
- As of writing this document, this is the most stable version. If you're not on this version,
23
- please upgrade yourself to latest version by installing node from [here](https://nodejs.org).
24
-
25
- Check your npm version by executing the following command.
26
-
27
- ```bash
28
-
29
- C:\projects>npm -v
30
- 3.10.8
31
-
32
- ```
33
-
34
- **_Your Application code sits on top of Ionic Framework and the Ionic Framework sits on top of Cordova._**
35
-
36
- Let's get them installed globally, so that all projects can use them.
37
-
38
- Execute the following commands.
39
-
40
- ```bash
41
-
42
- C:\projects>npm install -g cordova
43
-
44
- C:\projects>npm install -g ionic
45
-
46
- ```
47
-
48
- Once the above commands are executed successfully, Check the versions of cordova and ionic by executing the following commands.
49
-
50
- ```bash
51
-
52
- C:\projects>cordova -v
53
- 6.4.0
54
-
55
- C:\projects>ionic -v
56
- 2.1.8
57
-
58
- ```
59
-
60
- These are the latest versions as of writting this document.
61
-
62
- On successful execution of above commands, you're all set to create your Ionic app.
63
- To create your app, change into the directory where you want your app to reside and execute the following command
64
-
65
- ```bash
66
-
67
- C:\projects> ionic start Ionic_AngularFire_Project blank --v2
68
-
69
- ```
70
-
71
- >The command ionic start will create the project with name "Ionic_AngularFire_Project" using "blank" template.
72
-
73
- >The --v2 flag ensures, this is a Ionic2 project.
74
-
75
- Change to the project directory, which was just created with above command
76
-
77
- >C:\projects\Ionic_AngularFire_Project>
78
-
79
- To start your app, execute the following command
80
-
81
- ```bash
82
-
83
- C:\projects\Ionic_AngularFire_Project> ionic serve
84
-
85
- ```
86
-
87
- If everything is installed correctly, the app should open your browser with the dev server running at following url
88
- **`http://localhost:8100`** and will display default home page.
89
-
90
- Stop you server by pressing "ctrl + c", if it is still running from the above step and
91
- install typings and typescript globally by executing the following commands:
92
-
93
- **Note:-** typings is not required for our current application to work, but it will be helpful incase you want to bring in
94
- external libraries and extend this application.
95
-
96
- ```bash
97
-
98
- C:\projects\Ionic_AngularFire_Project>npm install -g typings
99
-
100
- C:\projects\Ionic_AngularFire_Project>npm install -g typescript
101
-
102
- ```
103
-
104
- Check typings and typescript versions by executing following commands:
105
-
106
- ```bash
107
-
108
- C:\projects\Ionic_AngularFire_Project>typings -v
109
- 2.0.0
110
-
111
- C:\projects\Ionic_AngularFire_Project>tsc -v
112
- Version 2.0.10
113
-
114
- ```
115
-
116
- ### Configuring AngularFire and Firebase
117
-
118
- Install AngularFire and firebase by executing the following command in your project directory
119
-
120
- ```ts
121
-
122
- C:\projects\Ionic_AngularFire_Project>npm install AngularFire firebase --save
123
-
124
- ```
125
-
126
- _This should add AngularFire and firebase entry in your project's package.json file in dependencies section. Something similar_
127
-
128
- >"AngularFire": "^2.0.0-beta.6",
129
-
130
- >"firebase": "^3.6.1",
131
-
132
- ### Setup @NgModule
133
-
134
- Open your project in your favourite editor and open the `app.module.ts` file, under `src/app`
135
- and add the following three entries.
136
-
137
- >1) Import AngularFireModule at top.
138
-
139
- >2) Define your firebaseConfig constant.
140
-
141
- >3) Initialize your app, by calling it in the "imports" array in @NgModule
142
-
143
- your `app.module.ts` file should look something like this.
144
-
145
- ```ts
146
-
147
- import { NgModule } from '@angular/core';
148
- import { IonicApp, IonicModule } from 'ionic-angular';
149
- import { MyApp } from './app.component';
150
- import { HomePage } from '../pages/home/home';
151
-
152
- import { AngularFireModule } from 'AngularFire';
153
-
154
- export const firebaseConfig = {
155
- apiKey: "xxxxxxxxxx",
156
- authDomain: "your-domain-name.firebaseapp.com",
157
- databaseURL: "https://your-domain-name.firebaseio.com",
158
- storageBucket: "your-domain-name.appspot.com",
159
- messagingSenderId: '<your-messaging-sender-id>'
160
- };
161
-
162
- @NgModule({
163
- declarations: [
164
- MyApp,
165
- HomePage
166
- ],
167
- imports: [
168
- IonicModule.forRoot(MyApp),
169
- AngularFireModule.initializeApp(firebaseConfig)
170
- ],
171
- bootstrap: [IonicApp],
172
- entryComponents: [
173
- MyApp,
174
- HomePage
175
- ],
176
- providers: []
177
- })
178
- export class AppModule { }
179
-
180
- ```
181
- ### Inject AngularFireDatabase and Bind it to List
182
-
183
- Now inject AngularFireDatabase in your component. Open your `home.ts` by going into `src/pages/home/home.ts` and make the following changes:
184
-
185
- >1) Import "AngularFireDatabase, FirebaseListObservable" at the top of your component.
186
-
187
- >2) Inject your AngularFireDatabase dependency in the constructor.
188
-
189
- >3) Call the list method on the AngularFireDatabase service.
190
-
191
- Your `home.ts` file should look like this.
192
-
193
- ```ts
194
-
195
- import { Component } from '@angular/core';
196
- import { NavController } from 'ionic-angular';
197
-
198
- import { AngularFireDatabase, FirebaseListObservable } from 'AngularFire/database';
199
-
200
- @Component({
201
- selector: 'page-home',
202
- templateUrl: 'home.html'
203
- })
204
- export class HomePage {
205
-
206
- items: FirebaseListObservable<any[]>;
207
-
208
- constructor(public navCtrl: NavController, db: AngularFireDatabase) {
209
- this.items = db.list('/items');
210
- }
211
-
212
- }
213
-
214
- ```
215
-
216
- **Update** your `home.html` at `src/pages/home/home.html`, with following entry
217
-
218
- ```html
219
-
220
- <ion-header>
221
- <ion-navbar>
222
- <ion-title>
223
- Ionic Blank
224
- </ion-title>
225
- </ion-navbar>
226
- </ion-header>
227
-
228
- <ion-content padding>
229
- <ion-list>
230
- <ion-item class="text" *ngFor="let item of items | async">
231
- {{item.$value}}
232
- </ion-item>
233
- </ion-list>
234
- </ion-content>
235
-
236
- ```
237
-
238
- ** Run your app by executing the following command **
239
-
240
- ```bash
241
-
242
- C:\projects\Ionic_AngularFire_Project> ionic serve
243
-
244
- ```
245
-
246
- This should fetch the data from firebase.
247
-
248
- ## Configuring AngularFire Auth with Ionic2
249
-
250
- Continuing with the above example stop your server by pressing `ctrl+c` and go to command prompt and
251
- generate a service by executing the following command
252
-
253
- ```bash
254
-
255
- C:\projects\Ionic_AngularFire_Project> ionic g provider AuthService
256
-
257
- ```
258
-
259
- This should create the AuthService under `src/providers/auth-service.ts`.
260
- Update the service with the following code.
261
-
262
- ```typescript
263
- import { Observable } from 'rxjs/Observable';
264
- import { Injectable } from '@angular/core';
265
- import { AngularFireAuth } from 'AngularFire/auth';
266
- // Do not import from 'firebase' as you'll lose the tree shaking benefits
267
- import firebase from 'firebase/app';
268
-
269
- @Injectable()
270
- export class AuthService {
271
- private currentUser: firebase.User;
272
-
273
- constructor(public afAuth: AngularFireAuth) {
274
- afAuth.authState.subscribe((user: firebase.User) => this.currentUser = user);
275
- }
276
-
277
- get authenticated(): boolean {
278
- return this.currentUser !== null;
279
- }
280
-
281
- signInWithFacebook(): firebase.Promise<any> {
282
- return this.afAuth.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider());
283
- }
284
-
285
- signOut(): void {
286
- this.afAuth.auth.signOut();
287
- }
288
-
289
- displayName(): string {
290
- if (this.currentUser !== null) {
291
- return this.currentUser.facebook.displayName;
292
- } else {
293
- return '';
294
- }
295
- }
296
- }
297
-
298
- ```
299
-
300
- Add your service in `app.module.ts`. Your `app.module.ts` should look like this
301
-
302
- ```ts
303
-
304
- import { NgModule } from '@angular/core';
305
- import { IonicApp, IonicModule } from 'ionic-angular';
306
- import { MyApp } from './app.component';
307
- import { HomePage } from '../pages/home/home';
308
-
309
- import { AngularFireModule } from 'AngularFire';
310
- import { AuthService } from '../providers/auth-service';
311
-
312
-
313
- export const firebaseConfig = {
314
- apiKey: "xxxxxxxxxx",
315
- authDomain: "your-domain-name.firebaseapp.com",
316
- databaseURL: "https://your-domain-name.firebaseio.com",
317
- storageBucket: "your-domain-name.appspot.com",
318
- messagingSenderId: '<your-messaging-sender-id>'
319
- };
320
-
321
- @NgModule({
322
- declarations: [
323
- MyApp,
324
- HomePage
325
- ],
326
- imports: [
327
- IonicModule.forRoot(MyApp),
328
- AngularFireModule.initializeApp(firebaseConfig)
329
- ],
330
- bootstrap: [IonicApp],
331
- entryComponents: [
332
- MyApp,
333
- HomePage
334
- ],
335
- providers: [AuthService]
336
- })
337
- export class AppModule { }
338
-
339
- ```
340
-
341
- Update your `home.html` to add a login button. Your `home.html` should look like this
342
-
343
- ```html
344
-
345
- <ion-header>
346
- <ion-navbar>
347
- <ion-title>
348
- Ionic Blank
349
- </ion-title>
350
- </ion-navbar>
351
- </ion-header>
352
-
353
- <ion-content padding>
354
- <ion-list>
355
- <ion-item class="text" *ngFor="let item of items | async">
356
- {{item | json}}
357
- </ion-item>
358
- </ion-list>
359
-
360
- <button ion-button outline (click)="signInWithFacebook()">Facebook</button>
361
- </ion-content>
362
-
363
- ```
364
-
365
- and finally, add the corresponding click handlers in `home.ts` as follows.
366
- Also, ensure the *AuthService* is injected in the constructor. Your `home.ts` should look like this
367
-
368
- ```ts
369
-
370
- import { Component } from '@angular/core';
371
- import { NavController } from 'ionic-angular';
372
-
373
- import { AuthService } from '../../providers/auth-service';
374
- import { AngularFireDatabase, FirebaseListObservable } from 'AngularFire/database';
375
-
376
- @Component({
377
- selector: 'page-home',
378
- templateUrl: 'home.html'
379
- })
380
- export class HomePage {
381
-
382
- items: FirebaseListObservable<any[]>;
383
-
384
- constructor(public navCtrl: NavController, db: AngularFireDatabase, private _auth: AuthService) {
385
- this.items = db.list('/items');
386
- }
387
-
388
- signInWithFacebook(): void {
389
- this._auth.signInWithFacebook()
390
- .then(() => this.onSignInSuccess());
391
- }
392
-
393
- private onSignInSuccess(): void {
394
- console.log("Facebook display name ",this._auth.displayName());
395
- }
396
-
397
- }
398
-
399
- ```
400
-
401
- Now run your app and if everything is configured correctly, you should be able to click on the login button in your app,
402
- which should open the facebook pop-up.
403
-
404
- Once you authenticate yourself, you should see your Facebook display name in console.
405
-
406
- You can try redirecting yourself to another page to grab additional details from Facebook.
407
-
408
-
409
- ***Running our application on mobile phone.***
410
-
411
- Ensure you've the platform added to your project. If not add the platform by executing the following command.
412
-
413
- ```
414
-
415
- C:\projects\Ionic_AngularFire_Project>ionic platform add android
416
-
417
- ```
418
-
419
- This adds android platform for your project.
420
- Replace android with ios, if you're on Mac book or add both. The generic command is ```ionic platform add <platform-name>```
421
-
422
- Now, let's try to run the app in browser. Execute the command
423
-
424
- ```
425
-
426
- C:\projects\Ionic_AngularFire_Project> ionic run android
427
-
428
- ```
429
-
430
- This should run the app on your mobile phone. Now click on the Facebook button and you'll notice the button doesn't work anymore.
431
- This is because the code written so far is good for running our application in browsers, but when running the application on mobile phones, we need to have access to ***Native Mobile API's***, which are provided by _Cordova Plugins_.
432
-
433
- **We can access these cordova plugins, using Ionic Native, which are nothing but wrappers for cordova plugins.**
434
-
435
- List of all Ionic Native API's for cordova plugins can be found [here](http://ionicframework.com/docs/v2/native/).
436
-
437
- Let's look at configuring and installing facebook plugin [here](http://ionicframework.com/docs/v2/native/facebook/).
438
- _Ensure you follow the steps correctly to configure your app._
439
-
440
- Once you create your app and make a note of your App ID, go to command prompt in your project directory and execute the following command
441
-
442
- ```
443
- C:\projects\Ionic_AngularFire_Project>
444
- ionic plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApp"
445
-
446
- ```
447
-
448
- Replace App ID with your app id from portal and provide your app name.
449
-
450
- This will install the cordova plugin for facebook.
451
-
452
- Add the platform to your facebook portal as mentioned in the document [here](http://ionicframework.com/docs/v2/native/facebook/).
453
-
454
- Now import the Platform and Facebook objects in your ```auth-service.ts```
455
-
456
- ```ts
457
- import { Platform } from 'ionic-angular';
458
- import { Facebook } from 'ionic-native';
459
- ```
460
-
461
- and update the signInWithFacebook() method.
462
-
463
- your ```auth-service.ts``` code should look like this.
464
-
465
- ```ts
466
- import { Observable } from 'rxjs/Observable';
467
- import { Injectable } from '@angular/core';
468
- import { AngularFireAuth } from 'AngularFire/auth';
469
- // Do not import from 'firebase' as you'll lose the tree shaking benefits
470
- import firebase from 'firebase/app';
471
-
472
- import { Platform } from 'ionic-angular';
473
- import { Facebook } from 'ionic-native';
474
-
475
- @Injectable()
476
- export class AuthService {
477
- private currentUser: firebase.User;
478
-
479
- constructor(public afAuth: AngularFireAuth) {
480
- afAuth.authState.subscribe((user: firebase.User) => this.currentUser = user);
481
- }
482
-
483
- get authenticated(): boolean {
484
- return this.currentUser !== null;
485
- }
486
-
487
- signInWithFacebook(): firebase.Promise<any> {
488
- if (this.platform.is('cordova')) {
489
- return Facebook.login(['email', 'public_profile']).then(res => {
490
- const facebookCredential = firebase.auth.FacebookAuthProvider.credential(res.authResponse.accessToken);
491
- return this.afAuth.auth.signInWithCredential(facebookCredential);
492
- });
493
- } else {
494
- return this.afAuth.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider());
495
- }
496
-
497
- }
498
-
499
- signOut(): void {
500
- this.afAuth.auth.signOut();
501
- }
502
-
503
- displayName(): string {
504
- if (this.currentUser !== null) {
505
- return this.currentUser.facebook.displayName;
506
- } else {
507
- return '';
508
- }
509
- }
510
- }
511
-
512
-
513
- ```
514
-
515
- Verfiy your app is running in browser by executing the following command
516
-
517
- ```
518
-
519
- C:\projects\Ionic_AngularFire_Project>ionic serve
520
-
521
- ```
522
-
523
- Everything should work. Now trying running the app on your android phone
524
-
525
- ```
526
-
527
- C:\projects\Ionic_AngularFire_Project> ionic run android
528
-
529
- ```
530
-
531
- Once the App launches click on the Facebook login button and it should open up the native facebook app for authentication and once your enter credentials and gets succesfully authenticated, it should redirect you back to the home page.