Skip to content

Commit 39be4c5

Browse files
authored
docs: correct angular example (#111)
* Update README.md * docs: add angular `init` hook instruction
1 parent 68fcf8b commit 39be4c5

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,36 @@ Register plugin and manually initialize
4242
```ts
4343
import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
4444

45+
// use hook after platform dom ready
4546
GoogleAuth.init()
4647
```
4748

49+
4850
Use it
4951
```ts
5052
GoogleAuth.signIn()
5153
```
5254

5355
#### AngularFire2
56+
57+
init hook
58+
```ts
59+
// app.component.ts
60+
constructor() {
61+
this.initializeApp();
62+
}
63+
64+
initializeApp() {
65+
this.platform.ready().then(() => {
66+
GoogleAuth.init()
67+
})
68+
}
69+
```
70+
71+
sign in function
5472
```ts
5573
async googleSignIn() {
56-
let googleUser = await Plugins.GoogleAuth.signIn();
74+
let googleUser = await GoogleAuth.signIn();
5775
const credential = auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);
5876
return this.afAuth.auth.signInAndRetrieveDataWithCredential(credential);
5977
}
@@ -126,7 +144,7 @@ Provide configuration in root `capacitor.config.json`
126144
Note : `forceCodeForRefreshToken` force user to select email address to regenerate AuthCode used to get a valid refreshtoken (work on iOS and Android) (This is used for offline access and serverside handling)
127145

128146

129-
### Migration guide
147+
## Migration guide
130148

131149
#### Migrate from 2 to 3
132150

@@ -136,7 +154,7 @@ After [migrate to Capcitor 3](https://capacitorjs.com/docs/updating/3-0) updatin
136154
```diff
137155
- import "@codetrix-studio/capacitor-google-auth";
138156
- import { Plugins } from '@capacitor/core';
139-
+ import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
157+
+ import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth'
140158

141159
- Plugins.GoogleAuth.signIn();
142160
+ GoogleAuth.init()

0 commit comments

Comments
 (0)