@@ -12,34 +12,34 @@ This tutorial uses **Facebook** as the sign-in provider. After completion of thi
12
12
other sign-in providers like ** Twitter** , ** Google** on your own.
13
13
14
14
### Prerequisites
15
- The first step is to ensure you've latest version of ** Node** installed.
15
+ The first step is to ensure you have latest version of ** Node** installed.
16
16
You can get the latest version from [ here] ( https://nodejs.org ) .
17
17
This will install both node and npm.
18
18
19
- After installing node, check the version by executing the following command in your prompt window.
19
+ After installing node, check the version by executing the following command in your prompt window:
20
20
21
21
``` bash
22
22
23
23
C:\p rojects> node -v
24
24
v6.10.2
25
25
26
26
```
27
- As of writting this document , this is the most stable version. If you're not on this version,
27
+ As of this writing , this is the most stable version. If you're not on this version,
28
28
please upgrade yourself to latest version by installing node from [ here] ( https://nodejs.org ) .
29
29
30
- Check your npm version by executing the following command.
30
+ Check your npm version by executing the following command:
31
31
``` bash
32
32
33
33
C:\p rojects> npm -v
34
34
3.10.10
35
35
36
36
```
37
- Install the Angular CLI, which will be used to build our Angular project and install Angular version 4 later.
37
+ Install the Angular CLI, which will be used to build our Angular project and install Angular version 4 or later.
38
38
39
39
``` bash
40
40
C:\p rojects> npm install -g @angular/cli
41
41
```
42
- Check your angular version by executing the following command.
42
+ Check your angular version by executing the following command:
43
43
44
44
``` bash
45
45
C:\p rojects> ng -v
@@ -63,7 +63,7 @@ C:\projects>npm install -g ionic
63
63
64
64
```
65
65
66
- Once the above commands are executed successfully, Check the versions of cordova and ionic by executing the following commands.
66
+ Once the above commands are executed successfully, check the versions of cordova and ionic by executing the following commands.
67
67
68
68
``` bash
69
69
C:\p rojects> cordova -v
@@ -73,19 +73,19 @@ C:\projects>ionic -v
73
73
3.4.0
74
74
```
75
75
76
- These are the latest versions as of writting this document .
76
+ These are the latest versions as of this writing .
77
77
78
- On successful execution of above commands, you're all set to create your app with Ionic framework.
78
+ On successful execution of the above commands, you're all set to create your app with Ionic framework.
79
79
80
- To create your app, change into the directory where you want your app to reside and execute the following command
80
+ To create your app, change into the directory where you want your app to reside and execute the following command:
81
81
82
82
``` bash
83
83
C:\p rojects> ionic start auth-ng4-ionic3-af2 blank
84
84
```
85
85
86
86
> The command ionic start will create the project with name "Ionic_AngularFire2_Project" using "blank" template.
87
87
88
- Change to the project directory, which was just created with above command
88
+ Change to the project directory, which was just created with the above command.
89
89
90
90
> C:\projects\auth-ng4-ionic3-af2>ionic info
91
91
@@ -115,7 +115,7 @@ System:
115
115
```
116
116
You need to ensure you've got Ionic Framework Version 3, as shown above.
117
117
118
- Alternatively you can open ` package.json ` to ensure you've got the following angualr and Ionic versions
118
+ Alternatively you can open ` package.json ` to ensure you've got the following Angular and Ionic versions:
119
119
120
120
``` json
121
121
"dependencies" : {
@@ -147,23 +147,23 @@ Alternatively you can open `package.json` to ensure you've got the following ang
147
147
148
148
If not, replace them to match above. These are the latest as of writing this tutorial.
149
149
150
- To start your app, execute the following command
150
+ To start your app, execute the following command:
151
151
152
152
``` bash
153
153
154
154
C:\p rojects\a uth-ng4-ionic3-af2> ionic serve
155
155
156
156
```
157
- If everything is installed correctly, the app should open your browser with the dev server running at following url
157
+ If everything is installed correctly, the app should open your browser with the dev server running at the following url
158
158
** ` http://localhost:8100 ` ** and will display default home page.
159
159
160
160
### Configuring AngularFire2 and Firebase
161
161
162
- Install angularfire2 and firebase by executing the following command in your project directory
162
+ Install angularfire2 and firebase by executing the following command in your project directory:
163
163
164
164
``` ts
165
165
166
- C :\projects \auth - ng4 - ionic3 - af2 > npm install angularfire2 firebase -- save
166
+ C :\projects \auth - ng4 - ionic3 - af2 > npm install angularfire2 firebase promise - polyfill -- save
167
167
168
168
```
169
169
@@ -182,9 +182,9 @@ and add the following three entries.
182
182
183
183
> 2 ) Define your firebaseConfig constant.
184
184
185
- > 3 ) Initialize your app, by adding AngularFireModule in the "imports" array in @NgModule
185
+ > 3 ) Initialize your app, by adding AngularFireModule and AngularFireAuthModule in the "imports" array in @NgModule
186
186
187
- > 3 ) Also, add AngularFireDatabaseModule in the "imports " array in @NgModule
187
+ > 4 ) Also, add AngularFireDatabase in the "providers " array in @NgModule
188
188
189
189
your ` app.module.ts ` file should look something like this.
190
190
@@ -231,6 +231,7 @@ export const firebaseConfig = {
231
231
providers: [
232
232
StatusBar ,
233
233
SplashScreen ,
234
+ AngularFireDatabase ,
234
235
{provide: ErrorHandler , useClass: IonicErrorHandler }
235
236
]
236
237
})
@@ -249,7 +250,7 @@ following changes:
249
250
250
251
> 3 ) Call the list method on AngularFireDatabase object.
251
252
252
- Your ` home.ts ` file should look like this.
253
+ Your ` home.ts ` file should look like this:
253
254
254
255
``` typescript
255
256
@@ -403,7 +404,7 @@ Also, update your `app.module.ts` to contain following import
403
404
and add it to the imports array.
404
405
405
406
406
- Run the app and click on the Login Button, you should see a pop-up asking you to enter username and password for facebook to
407
+ Run the app and click on the Login Button, you should see a pop-up asking you to enter username and password for Facebook to
407
408
authenticate. Once authenticated, you should see the response from Facebook in console window.
408
409
409
410
Inspect the Object in the console, under ` user ` property, you should see all the attributes and we're going to use two of them, next.
@@ -459,7 +460,7 @@ export class HomePage {
459
460
460
461
```
461
462
462
- and ` home.html ` shouldlook like this
463
+ and ` home.html ` should look like this:
463
464
464
465
``` html
465
466
@@ -487,12 +488,12 @@ which should open the facebook pop-up.
487
488
Once you authenticate yourself, you should see your Facebook display name on your screen.
488
489
Click the Logout button, which will make the AuthState to null and you should see the difference on your screen.
489
490
490
- You can try redirecting yourself to another page to grab additional details from Facebook and experiement on your own.
491
+ You can try redirecting yourself to another page to grab additional details from Facebook and experiment on your own.
491
492
492
493
493
494
*** Running our application on mobile phone***
494
495
495
- Ensure you've the platform added to your project. If not add the platform by executing the following command.
496
+ Ensure you've the platform added to your project. If not add the platform by executing the following command:
496
497
497
498
```
498
499
@@ -503,7 +504,7 @@ C:\projects\auth-ng4-ionic3-af2>ionic platform add android
503
504
This adds android platform for your project.
504
505
Replace android with ios, if you're on Mac book or add both. The generic command is ``` ionic platform add <platform-name> ```
505
506
506
- Now, let's try to run the app in browser. Execute the command
507
+ Now, let's try to run the app in browser. Execute the command:
507
508
508
509
```
509
510
@@ -519,10 +520,10 @@ mobile phones, we need to have access to ***Native Mobile API's***, which are pr
519
520
520
521
List of all Ionic Native API's for cordova plugins can be found [ here] ( http://ionicframework.com/docs/v2/native/ ) .
521
522
522
- Let's look at configuring and installing facebook plugin [ here] ( http://ionicframework.com/docs/v2/native/facebook/ ) .
523
+ Let's look at configuring and installing the Facebook plugin [ here] ( http://ionicframework.com/docs/v2/native/facebook/ ) .
523
524
_ Ensure you follow the steps correctly to configure your app._
524
525
525
- Login to facebook dashboard [ here] ( https://developers.facebook.com/apps/ ) , go to your App and make a note of your App ID.
526
+ Login to the Facebook dashboard [ here] ( https://developers.facebook.com/apps/ ) , go to your App and make a note of your App ID.
526
527
Next go to command prompt in your project directory and execute the following command by replacing the ` APP_ID ` with your App Id
527
528
and ` APP_NAME ` with your App Name.
528
529
@@ -533,7 +534,7 @@ ionic cordova plugin add cordova-plugin-facebook4 --variable APP_ID="123456789"
533
534
534
535
```
535
536
536
- This should add following entry in your config.xml, located at the root of your project.
537
+ This should add the following entry in your config.xml, located at the root of your project:
537
538
538
539
``` xml
539
540
@@ -547,15 +548,15 @@ This will install the cordova plugin for facebook.
547
548
548
549
You should also see a sub-folder named ` cordova-plugin-facebook4 ` under your ` plugins ` folder.
549
550
550
- Add the native dependencies by executing the following command.
551
+ Add the native dependencies by executing the following command:
551
552
552
553
``` bash
553
554
554
555
C:\p rojects\a uth-ng4-ionic3-af2> npm install --save @ionic-native/facebook
555
556
556
557
```
557
558
558
- After executing the above command, ensure you got following entry in your ` package.json `
559
+ After executing the above command, ensure you have the following entry in your ` package.json ` :
559
560
560
561
``` bash
561
562
@@ -573,7 +574,7 @@ import { Facebook } from '@ionic-native/facebook';
573
574
574
575
Update the "signInWithFacebook" method and use Platform Service to determine the platform and run the appropriate code.
575
576
576
- your ` home.ts ` should look as below
577
+ Your ` home.ts ` should look as below:
577
578
578
579
``` typescript
579
580
@@ -630,7 +631,7 @@ export class HomePage {
630
631
631
632
You'll also need to add the "Facebook" object in the provider section in app.module.ts.
632
633
633
- The final ` app.module.ts ` should look like below
634
+ The final ` app.module.ts ` should look like below:
634
635
635
636
``` typescript
636
637
@@ -685,21 +686,21 @@ export class AppModule {}
685
686
686
687
```
687
688
688
- Verfiy your app is running in browser by executing the following command
689
+ Verfiy your app is running in browser by executing the following command:
689
690
690
691
``` bash
691
692
692
693
C:\p rojects\a uth-ng4-ionic3-af2> ionic serve
693
694
694
695
```
695
696
696
- Everything should work. Now trying running the app on your android phone
697
+ Everything should work. Now trying running the app on your android phone:
697
698
698
699
``` bash
699
700
700
701
C:\p rojects\a uth-ng4-ionic3-af2> ionic cordova run android
701
702
702
703
```
703
704
704
- Once the App launches click on the Login button. You should get the facebook pop-up window. Enter your credentials.
705
+ Once the App launches click on the Login button. You should get the Facebook pop-up window. Enter your credentials.
705
706
On successful authentication, you should see your Facebook Display name and profile picture on your screen.
0 commit comments