Skip to content

Commit 53d2c51

Browse files
committed
chore: update demo
1 parent cfe8f47 commit 53d2c51

File tree

4 files changed

+52
-10
lines changed

4 files changed

+52
-10
lines changed

apps/demo/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"@nativescript/firebase-messaging": "file:../../packages/firebase-messaging",
2121
"@nativescript/firebase-performance": "file:../../packages/firebase-performance",
2222
"@nativescript/firebase-remote-config": "file:../../packages/firebase-remote-config",
23-
"@nativescript/firebase-storage": "file:../../packages/firebase-storage"
23+
"@nativescript/firebase-storage": "file:../../packages/firebase-storage",
24+
"@nativescript/google-signin": "^1.0.0-alpha.9"
2425
},
2526
"devDependencies": {
2627
"@nativescript/android": "8.2.0-alpha.2",

apps/demo/src/plugin-demos/firebase-admob.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ export class DemoModel extends DemoSharedFirebaseAdmob {
2727
// ATTrackingManager.requestTrackingAuthorizationWithCompletionHandler((status) => {
2828
// console.log('ATTrackingManager', status);
2929
// });
30-
3130
const testDevices = [];
3231
if (global.isIOS) {
33-
testDevices.push('b70c144077402b91cf8ecc5b93ac7791');
32+
testDevices.push('b70c144077402b91cf8ecc5b93ac7791', 'EMULATOR');
3433
} else {
3534
testDevices.push('EMULATOR');
3635
}
@@ -67,7 +66,7 @@ export class DemoModel extends DemoSharedFirebaseAdmob {
6766
view.nativeAd = ad;
6867
console.log('nativead loaded');
6968
} else if (event === 'adFailedToLoad') {
70-
console.log('nativead failed to load', error);
69+
console.error('nativead failed to load', error);
7170
}
7271
});
7372
loader.load();

apps/demo/src/plugin-demos/firebase-auth.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import { Observable, EventData, Page, fromObject } from '@nativescript/core';
1+
import { Observable, EventData, Page, fromObject, Application } from '@nativescript/core';
22
import { DemoSharedFirebaseAuth } from '@demo/shared';
33
import { firebase, Firebase } from '@nativescript/firebase-core';
44
import '@nativescript/firebase-auth';
5-
import { Auth, User, OAuthProvider, PhoneAuthProvider } from '@nativescript/firebase-auth';
5+
import { Auth, User, OAuthProvider, PhoneAuthProvider, GoogleAuthProvider } from '@nativescript/firebase-auth';
6+
import { GoogleSignin } from '@nativescript/google-signin';
7+
68
export function navigatingTo(args: EventData) {
79
const page = <Page>args.object;
810
page.bindingContext = new DemoModel();
911
}
1012

13+
14+
let didInit = false;
1115
export class DemoModel extends DemoSharedFirebaseAuth {
1216
email: string;
1317
password: string;
@@ -25,6 +29,28 @@ export class DemoModel extends DemoSharedFirebaseAuth {
2529
});
2630
}
2731

32+
async linkGoogle() {
33+
try {
34+
if (!this.user) {
35+
return;
36+
}
37+
if (!didInit) {
38+
await GoogleSignin.configure();
39+
didInit = true;
40+
}
41+
const isAvailable = await GoogleSignin.playServicesAvailable();
42+
if (!isAvailable) {
43+
return;
44+
}
45+
const user = await GoogleSignin.signIn();
46+
const cred = GoogleAuthProvider.credential(user.idToken, user.accessToken)
47+
const linked = await this.user.linkWithCredential(cred);
48+
console.log(linked);
49+
} catch (e) {
50+
console.log('linkGoogle', e.native);
51+
}
52+
}
53+
2854
async linkPhone() {
2955
if (!firebase().auth().currentUser) {
3056
console.info('Login to link phone');

tools/assets/App_Resources/Android/src/google-services.json renamed to tools/assets/App_Resources/Android/src/main/google-services.json

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
"certificate_hash": "17816f5cf2666cabd896c79e4957884c23f016da"
2323
}
2424
},
25+
{
26+
"client_id": "292142294722-u1eosqh9eco1l5isgau2805df2lvk0ek.apps.googleusercontent.com",
27+
"client_type": 1,
28+
"android_info": {
29+
"package_name": "io.github.triniwiz.nativescript.firebasedemo",
30+
"certificate_hash": "dad4ffbd27b6435c3fe5250c4d7d2195fa72fafb"
31+
}
32+
},
2533
{
2634
"client_id": "292142294722-uenpeed8drufjhsgfj9vhk3o73l9vp6b.apps.googleusercontent.com",
2735
"client_type": 3
@@ -40,10 +48,10 @@
4048
"client_type": 3
4149
},
4250
{
43-
"client_id": "292142294722-f7842ip6j9s72g2vp9rc8hd18hb9h4en.apps.googleusercontent.com",
51+
"client_id": "292142294722-23nmrq9mn8rhpqipjc1bt4qecga3qgsf.apps.googleusercontent.com",
4452
"client_type": 2,
4553
"ios_info": {
46-
"bundle_id": "org.nativescript.firebasedemo"
54+
"bundle_id": "io.github.triniwiz.nativescript.firebasedemo"
4755
}
4856
}
4957
]
@@ -58,6 +66,14 @@
5866
}
5967
},
6068
"oauth_client": [
69+
{
70+
"client_id": "292142294722-9s58kof5a3ng34vqhj51gs04qlr6jjgf.apps.googleusercontent.com",
71+
"client_type": 1,
72+
"android_info": {
73+
"package_name": "org.nativescript.firebasedemo",
74+
"certificate_hash": "dad4ffbd27b6435c3fe5250c4d7d2195fa72fafb"
75+
}
76+
},
6177
{
6278
"client_id": "292142294722-p4kc740vu3rtfgvmmcmnntsk2qb6niah.apps.googleusercontent.com",
6379
"client_type": 1,
@@ -84,10 +100,10 @@
84100
"client_type": 3
85101
},
86102
{
87-
"client_id": "292142294722-f7842ip6j9s72g2vp9rc8hd18hb9h4en.apps.googleusercontent.com",
103+
"client_id": "292142294722-23nmrq9mn8rhpqipjc1bt4qecga3qgsf.apps.googleusercontent.com",
88104
"client_type": 2,
89105
"ios_info": {
90-
"bundle_id": "org.nativescript.firebasedemo"
106+
"bundle_id": "io.github.triniwiz.nativescript.firebasedemo"
91107
}
92108
}
93109
]

0 commit comments

Comments
 (0)