Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 872a004

Browse files
Firestore anytime soon? #507
1 parent 6675ca5 commit 872a004

27 files changed

+779
-7363
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ install:
2222
- tns error-reporting disable
2323
- cd src
2424
- npm i --ignore-scripts
25-
- npm run build
25+
- npm run tsc
2626
- cd ../demo
2727
- npm i
2828

demo-ng/app/App_Resources/Android/app.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ android {
99
defaultConfig {
1010
generatedDensities = []
1111
multiDexEnabled true
12-
applicationId "org.nativescript.firebasedemo"
12+
applicationId "org.nativescript.firebasedemo.firestore"
1313
}
1414

1515
// after adding a few additional Firebase libs we'll need this (otherwise: OutOfMemoryException)

demo-ng/app/App_Resources/Android/google-services.json

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,27 @@
11
{
22
"project_info": {
3-
"project_number": "1052836194035",
4-
"firebase_url": "https://n-plugin-test.firebaseio.com",
5-
"project_id": "n-plugin-test",
6-
"storage_bucket": "n-plugin-test.appspot.com"
3+
"project_number": "176080762547",
4+
"firebase_url": "https://n-plugin-test-firestore.firebaseio.com",
5+
"project_id": "n-plugin-test-firestore",
6+
"storage_bucket": "n-plugin-test-firestore.appspot.com"
77
},
88
"client": [
99
{
1010
"client_info": {
11-
"mobilesdk_app_id": "1:1052836194035:android:443e3741d53b6bc3",
11+
"mobilesdk_app_id": "1:176080762547:android:fbe95ab1f255d884",
1212
"android_client_info": {
13-
"package_name": "org.nativescript.firebasedemo"
13+
"package_name": "org.nativescript.firebasedemo.firestore"
1414
}
1515
},
1616
"oauth_client": [
1717
{
18-
"client_id": "1052836194035-jtaui0ukukm0o8peubst87stchckm6cu.apps.googleusercontent.com",
19-
"client_type": 1,
20-
"android_info": {
21-
"package_name": "org.nativescript.firebasedemo",
22-
"certificate_hash": "c50c24d7261f8a41c00c641cf19b5116326b333b"
23-
}
24-
},
25-
{
26-
"client_id": "1052836194035-p5uj5vhmbnsc65sgkqeon8a5ja6bjhvi.apps.googleusercontent.com",
27-
"client_type": 1,
28-
"android_info": {
29-
"package_name": "org.nativescript.firebasedemo",
30-
"certificate_hash": "86bfaa9359cd32b94a0db4e71381d7f553e29efe"
31-
}
32-
},
33-
{
34-
"client_id": "1052836194035-om4t43ap2n4rt9q6jjr407tm3vad1qim.apps.googleusercontent.com",
35-
"client_type": 1,
36-
"android_info": {
37-
"package_name": "org.nativescript.firebasedemo",
38-
"certificate_hash": "f7e078e5bfcaa18db892f8ccc50a82e1775fb272"
39-
}
40-
},
41-
{
42-
"client_id": "1052836194035-mvghp8j5h3eh17c0n1dl0pkaeum8hjii.apps.googleusercontent.com",
18+
"client_id": "176080762547-e030nqu3u61ntnq5d3jilip6ik6au4cq.apps.googleusercontent.com",
4319
"client_type": 3
4420
}
4521
],
4622
"api_key": [
4723
{
48-
"current_key": "AIzaSyDSMjaKslCCA-U4MZm_ZFQjkGP_mS0RQKM"
24+
"current_key": "AIzaSyCbzMMocv610ByMwPvcv2W0h45btMojqLw"
4925
}
5026
],
5127
"services": {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<resources>
3+
<!-- TODO this is the app id the other demo app -->
4+
<string name="facebook_app_id">126035687816994</string>
5+
</resources>

demo-ng/app/App_Resources/iOS/GoogleService-Info.plist

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,34 @@
77
<key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
88
<string>ca-app-pub-3940256099942544/4411468910</string>
99
<key>CLIENT_ID</key>
10-
<string>1052836194035-l81fsjai1u40ocnqjcpnoebnnsltt03b.apps.googleusercontent.com</string>
10+
<string>176080762547-8g2ls3h76dcgdt5uuingun2hiehl49r7.apps.googleusercontent.com</string>
1111
<key>REVERSED_CLIENT_ID</key>
12-
<string>com.googleusercontent.apps.1052836194035-l81fsjai1u40ocnqjcpnoebnnsltt03b</string>
12+
<string>com.googleusercontent.apps.176080762547-8g2ls3h76dcgdt5uuingun2hiehl49r7</string>
1313
<key>API_KEY</key>
14-
<string>AIzaSyDuXPZxKamjttwP_hYpnX7MvDoZWhAVVtk</string>
14+
<string>AIzaSyC6yOZO4Kl0yGyRdyH_Z_Q0DysqvNYt3l0</string>
1515
<key>GCM_SENDER_ID</key>
16-
<string>1052836194035</string>
16+
<string>176080762547</string>
1717
<key>PLIST_VERSION</key>
1818
<string>1</string>
1919
<key>BUNDLE_ID</key>
20-
<string>org.nativescript.firebasedemo</string>
20+
<string>org.nativescript.firebasedemo.firestore</string>
2121
<key>PROJECT_ID</key>
22-
<string>n-plugin-test</string>
22+
<string>n-plugin-test-firestore</string>
2323
<key>STORAGE_BUCKET</key>
24-
<string>n-plugin-test.appspot.com</string>
24+
<string>n-plugin-test-firestore.appspot.com</string>
2525
<key>IS_ADS_ENABLED</key>
26-
<true/>
26+
<true></true>
2727
<key>IS_ANALYTICS_ENABLED</key>
28-
<false/>
28+
<false></false>
2929
<key>IS_APPINVITE_ENABLED</key>
30-
<false/>
30+
<false></false>
3131
<key>IS_GCM_ENABLED</key>
32-
<true/>
32+
<true></true>
3333
<key>IS_SIGNIN_ENABLED</key>
34-
<true/>
34+
<true></true>
3535
<key>GOOGLE_APP_ID</key>
36-
<string>1:1052836194035:ios:443e3741d53b6bc3</string>
36+
<string>1:176080762547:ios:fbe95ab1f255d884</string>
3737
<key>DATABASE_URL</key>
38-
<string>https://n-plugin-test.firebaseio.com</string>
38+
<string>https://n-plugin-test-firestore.firebaseio.com</string>
3939
</dict>
4040
</plist>

demo-ng/app/app.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,58 @@ of writing your own CSS rules. For a full list of class names in the theme
1010
refer to http://docs.nativescript.org/ui/theme.
1111
*/
1212
@import 'nativescript-theme-core/css/core.light.css';
13+
14+
.h2 {
15+
font-size: 16;
16+
font-weight: bold;
17+
text-align: center;
18+
margin: 22 0 0 0;
19+
}
20+
21+
button {
22+
background-color: #6494AA;
23+
padding: 8 12;
24+
margin: 4 10;
25+
font-size: 13;
26+
border-radius: 4;
27+
}
28+
29+
.button {
30+
color: #ffffff;
31+
}
32+
33+
.button-positive {
34+
background-color: #90A959;
35+
}
36+
37+
.button-user {
38+
background-color: #E0A458;
39+
}
40+
41+
.button-state {
42+
background-color: #64A4FF;
43+
}
44+
45+
.button-company {
46+
background-color: #A63D40;
47+
}
48+
49+
.button-storage {
50+
background-color: #54AA77;
51+
}
52+
53+
.button-analytics {
54+
background-color: #BBBB77;
55+
}
56+
57+
.button-messaging {
58+
background-color: #6d996c;
59+
}
60+
61+
.button-crash {
62+
background-color: #d52c1e;
63+
}
64+
65+
.button-invites {
66+
background-color: #1832d5;
67+
}

demo-ng/app/item/items.component.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,14 @@
22
</ActionBar>
33

44
<StackLayout class="page">
5-
<Button text="login" (tap)="login()"></Button>
5+
<Label text="Authentication" class="h2"></Label>
6+
<Button text="login anonymously" (tap)="loginAnonymously()" class="button button-user"></Button>
7+
<Label text="Firestore" class="h2"></Label>
8+
<Button text="Add" (tap)="firestoreAdd()" class="button"></Button>
9+
<Button text="Set" (tap)="firestoreSet()" class="button"></Button>
10+
<Button text="Set (auto id)" (tap)="firestoreSetByAutoID()" class="button"></Button>
11+
<Button text="Update" (tap)="firestoreUpdate()" class="button"></Button>
12+
<Button text="Get" (tap)="firestoreGet()" class="button"></Button>
13+
<Button text="Delete" (tap)="firestoreDelete()" class="button"></Button>
14+
615
</StackLayout>

demo-ng/app/item/items.component.ts

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { Component, OnInit } from "@angular/core";
2+
import { firestore } from "nativescript-plugin-firebase";
3+
// import { firestore } from "nativescript-plugin-firebase/app/firestore";
4+
25
const firebase = require("nativescript-plugin-firebase/app");
36

47
@Component({
@@ -15,10 +18,64 @@ export class ItemsComponent implements OnInit {
1518
firebase.initializeApp();
1619
}
1720

18-
public login(): void {
19-
console.log(">>> login");
21+
public loginAnonymously(): void {
2022
firebase.auth().signInAnonymously()
2123
.then(() => console.log("Logged in"))
22-
.catch(err => console.log("Login error: " + err));
24+
.catch(err => console.log("Login error: " + JSON.stringify(err)));
25+
}
26+
27+
public firestoreAdd(): void {
28+
firebase.firestore().collection("dogs").add({name: "Fido"})
29+
.then((docRef: firestore.DocumentReference) => {
30+
console.log("Fido added, ref: " + docRef.id);
31+
})
32+
.catch(err => console.log("Adding Fido failed, error: " + err));
33+
}
34+
35+
public firestoreSet(): void {
36+
firebase.firestore().collection("dogs").doc("fave")
37+
.set({name: "Woofie", last: "lastofwoofie", date: new Date()}, {merge: true})
38+
.then(() => {
39+
console.log("Woofie set");
40+
})
41+
.catch(err => console.log("Setting Woofie failed, error: " + err));
42+
}
43+
44+
public firestoreSetByAutoID(): void {
45+
firebase.firestore().collection("dogs").doc()
46+
.set({name: "Woofie", last: "lastofwoofie", date: new Date()})
47+
.then(() => {
48+
console.log("Woofie set");
49+
})
50+
.catch(err => console.log("Setting Woofie failed, error: " + err));
51+
}
52+
53+
public firestoreUpdate(): void {
54+
firebase.firestore().collection("dogs").doc("fave")
55+
.update({name: "Woofieupdate", last: "updatedwoofie"})
56+
.then(() => {
57+
console.log("Woofie updated");
58+
})
59+
.catch(err => console.log("Updating Woofie failed, error: " + JSON.stringify(err)));
60+
}
61+
62+
public firestoreGet(): void {
63+
const collectionRef: firestore.CollectionReference = firebase.firestore().collection("dogs");
64+
collectionRef.get()
65+
.then((querySnapshot: firestore.QuerySnapshot) => {
66+
querySnapshot.forEach(doc => {
67+
console.log(`${doc.id} => ${JSON.stringify(doc.data())}`);
68+
});
69+
})
70+
.catch(err => console.log("Get failed, error" + err));
71+
}
72+
73+
public firestoreDelete(): void {
74+
firebase.firestore().collection("dogs").doc("fave")
75+
.delete()
76+
.then(() => {
77+
console.log("Woofie deleted");
78+
})
79+
.catch(err => console.log("Delete failed, error" + err));
2380
}
2481
}

demo-ng/app/main.aot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { platformNativeScript } from "nativescript-angular/platform-static";
33

44
import { AppModuleNgFactory } from "./app.module.ngfactory";
55

6-
const firebase = require("nativescript-plugin-firebase");
6+
require("nativescript-plugin-firebase");
77

88
platformNativeScript().bootstrapModuleFactory(AppModuleNgFactory);

demo-ng/app/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { platformNativeScriptDynamic } from "nativescript-angular/platform";
33

44
import { AppModule } from "./app.module";
55

6-
const firebase = require("nativescript-plugin-firebase");
6+
require("nativescript-plugin-firebase");
77

88
// A traditional NativeScript application starts by initializing global objects, setting up global CSS rules, creating, and navigating to the main page.
99
// Angular applications need to take care of their own initialization: modules, components, directives, routes, DI providers.

0 commit comments

Comments
 (0)