Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions docs/ionic/authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# STEP 1: install this plugin:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use capitalization instead of uppercase for the word "step". I find that when something is placed in uppercase by itself too many times it can come off a bit aggressive.

```
1) ionic cordova plugin add cordova-universal-links-plugin
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the numbers so it's copy and paste-able.

2) ionic cordova plugin add cordova-plugin-buildinfo
3) ionic cordova plugin add cordova-plugin-browsertab
4) ionic cordova plugin add cordova-plugin-inappbrowser
5) ionic cordova plugin add cordova-plugin-customurlscheme (for ios)
```

# STEP 2: Add Firebase to your Ionic

STEP 2.1: [setup firebase to angular project]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of sub numbering the steps just place the action in bold.

Setup Firebase to the Angular Project

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link formatting is broken here

(https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md)

STEP 2.2: To set up an Android app, go to [Firebase Console](https://console.firebase.google.com/) then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Small typo "To set up in an Android app, go to..."

Click **Add Firebase to your Android app** and follow the setup steps.

# STEP 3: Set up Firebase Authentication for Cordova ( sumary from [firebase instruction](https://firebase.google.com/docs/auth/web/cordova))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Spacing around parens and capitalization of proper nouns.

(Steps from Firebase documentation)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another nitpick: sumary should be summary


STEP 3.1: In the Firebase console, open the **Dynamic Links** section at bottom left panel, setup by they instruction
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: typo

setup by their instruction


STEP 3.2: add this to config.xml at root level of project:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use bold, capitalize "add", and backticks for config.xml

*Add this to config.xml at root level of project

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add syntax highlighting perhaps?

```xml

```

<universal-links>
<!-- this is dynamic link created in firebase -->
<host name="zm4e4.app.goo.gl" scheme="https" />
<!-- this is your firebase app link -->
<host name="routing-aadd4.firebaseapp.com" scheme="https">
<path url="/__/auth/callback" />
</host>
</universal-links>
<!-- for android -->
<preference name="AndroidLaunchMode" value="singleTask" />
```

STEP 3.3: make sure your `<widget id="com.yourandroid.id" ... >` the same with android app's id you
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure your..

added in firebase at STEP 2.2.

# STEP 4: add login code:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: capitalize "add"

at login.service.ts add this function:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: backticks for login.service.ts

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax highlighting here as well

```ts

```

import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import AuthProvider = firebase.auth.AuthProvider;

export class AuthService {
private user: firebase.User;
constructor(public afAuth: AngularFireAuth) {
afAuth.authState.subscribe(user => {
this.user = user;
});
}

signInWithFacebook() {
console.log('Sign in with google');
return this.oauthSignIn(new firebase.auth.FacebookAuthProvider());
}

signInWithGoogle() {
console.log('Sign in with google');
return this.oauthSignIn(new firebase.auth.GoogleAuthProvider());
}

private oauthSignIn(provider: AuthProvider) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code formatting is off in this sample. Try pasting it into an editor to clean it up for you and then paste it back in here.

if (!(<any>window).cordova) {
return this.afAuth.auth.signInWithPopup(provider);
} else {
return this.afAuth.auth.signInWithRedirect(provider)
.then(() => {
return this.afAuth.auth.getRedirectResult().then( result => {
// This gives you a Google Access Token.
// You can use it to access the Google API.
let token = result.credential.accessToken;
// The signed-in user info.
let user = result.user;
console.log(token, user);
}).catch(function(error) {
// Handle Errors here.
alert(error.message);
});
});
}
}
}
```

# Problem 1:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like that you have a common problems section. Try using that title as the header:

Common problems


if you got error when build code like this:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try: "If you received an error like this during a build"

`UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a three backtick code block here:

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined


Please, using this fix from [issue](https://github.com/nordnet/cordova-universal-links-plugin/issues/134):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try: "Use this fix from..."

> Making this change in 'cordova-universal-links-plugin/hooks/lib/android/manifestWriter.js' fixed this issue for me:
> [b2c5784#diff-d5955d9f4d88b42e5efd7a3385be79e9](https://github.com/nordnet/cordova-universal-links-plugin/commit/b2c5784764225319648e26aa5d3f42ede6d1b289#diff-d5955d9f4d88b42e5efd7a3385be79e9)