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

Commit

Permalink
Firestore anytime soon? #507
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Nov 26, 2017
1 parent 6675ca5 commit 872a004
Show file tree
Hide file tree
Showing 27 changed files with 779 additions and 7,363 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ install:
- tns error-reporting disable
- cd src
- npm i --ignore-scripts
- npm run build
- npm run tsc
- cd ../demo
- npm i

Expand Down
2 changes: 1 addition & 1 deletion demo-ng/app/App_Resources/Android/app.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
defaultConfig {
generatedDensities = []
multiDexEnabled true
applicationId "org.nativescript.firebasedemo"
applicationId "org.nativescript.firebasedemo.firestore"
}

// after adding a few additional Firebase libs we'll need this (otherwise: OutOfMemoryException)
Expand Down
40 changes: 8 additions & 32 deletions demo-ng/app/App_Resources/Android/google-services.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,27 @@
{
"project_info": {
"project_number": "1052836194035",
"firebase_url": "https://n-plugin-test.firebaseio.com",
"project_id": "n-plugin-test",
"storage_bucket": "n-plugin-test.appspot.com"
"project_number": "176080762547",
"firebase_url": "https://n-plugin-test-firestore.firebaseio.com",
"project_id": "n-plugin-test-firestore",
"storage_bucket": "n-plugin-test-firestore.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1052836194035:android:443e3741d53b6bc3",
"mobilesdk_app_id": "1:176080762547:android:fbe95ab1f255d884",
"android_client_info": {
"package_name": "org.nativescript.firebasedemo"
"package_name": "org.nativescript.firebasedemo.firestore"
}
},
"oauth_client": [
{
"client_id": "1052836194035-jtaui0ukukm0o8peubst87stchckm6cu.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "org.nativescript.firebasedemo",
"certificate_hash": "c50c24d7261f8a41c00c641cf19b5116326b333b"
}
},
{
"client_id": "1052836194035-p5uj5vhmbnsc65sgkqeon8a5ja6bjhvi.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "org.nativescript.firebasedemo",
"certificate_hash": "86bfaa9359cd32b94a0db4e71381d7f553e29efe"
}
},
{
"client_id": "1052836194035-om4t43ap2n4rt9q6jjr407tm3vad1qim.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "org.nativescript.firebasedemo",
"certificate_hash": "f7e078e5bfcaa18db892f8ccc50a82e1775fb272"
}
},
{
"client_id": "1052836194035-mvghp8j5h3eh17c0n1dl0pkaeum8hjii.apps.googleusercontent.com",
"client_id": "176080762547-e030nqu3u61ntnq5d3jilip6ik6au4cq.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDSMjaKslCCA-U4MZm_ZFQjkGP_mS0RQKM"
"current_key": "AIzaSyCbzMMocv610ByMwPvcv2W0h45btMojqLw"
}
],
"services": {
Expand Down
5 changes: 5 additions & 0 deletions demo-ng/app/App_Resources/Android/values/facebooklogin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<!-- TODO this is the app id the other demo app -->
<string name="facebook_app_id">126035687816994</string>
</resources>
28 changes: 14 additions & 14 deletions demo-ng/app/App_Resources/iOS/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@
<key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
<string>ca-app-pub-3940256099942544/4411468910</string>
<key>CLIENT_ID</key>
<string>1052836194035-l81fsjai1u40ocnqjcpnoebnnsltt03b.apps.googleusercontent.com</string>
<string>176080762547-8g2ls3h76dcgdt5uuingun2hiehl49r7.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.1052836194035-l81fsjai1u40ocnqjcpnoebnnsltt03b</string>
<string>com.googleusercontent.apps.176080762547-8g2ls3h76dcgdt5uuingun2hiehl49r7</string>
<key>API_KEY</key>
<string>AIzaSyDuXPZxKamjttwP_hYpnX7MvDoZWhAVVtk</string>
<string>AIzaSyC6yOZO4Kl0yGyRdyH_Z_Q0DysqvNYt3l0</string>
<key>GCM_SENDER_ID</key>
<string>1052836194035</string>
<string>176080762547</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>org.nativescript.firebasedemo</string>
<string>org.nativescript.firebasedemo.firestore</string>
<key>PROJECT_ID</key>
<string>n-plugin-test</string>
<string>n-plugin-test-firestore</string>
<key>STORAGE_BUCKET</key>
<string>n-plugin-test.appspot.com</string>
<string>n-plugin-test-firestore.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<true/>
<true></true>
<key>IS_ANALYTICS_ENABLED</key>
<false/>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<false/>
<false></false>
<key>IS_GCM_ENABLED</key>
<true/>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true/>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:1052836194035:ios:443e3741d53b6bc3</string>
<string>1:176080762547:ios:fbe95ab1f255d884</string>
<key>DATABASE_URL</key>
<string>https://n-plugin-test.firebaseio.com</string>
<string>https://n-plugin-test-firestore.firebaseio.com</string>
</dict>
</plist>
55 changes: 55 additions & 0 deletions demo-ng/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,58 @@ of writing your own CSS rules. For a full list of class names in the theme
refer to http://docs.nativescript.org/ui/theme.
*/
@import 'nativescript-theme-core/css/core.light.css';

.h2 {
font-size: 16;
font-weight: bold;
text-align: center;
margin: 22 0 0 0;
}

button {
background-color: #6494AA;
padding: 8 12;
margin: 4 10;
font-size: 13;
border-radius: 4;
}

.button {
color: #ffffff;
}

.button-positive {
background-color: #90A959;
}

.button-user {
background-color: #E0A458;
}

.button-state {
background-color: #64A4FF;
}

.button-company {
background-color: #A63D40;
}

.button-storage {
background-color: #54AA77;
}

.button-analytics {
background-color: #BBBB77;
}

.button-messaging {
background-color: #6d996c;
}

.button-crash {
background-color: #d52c1e;
}

.button-invites {
background-color: #1832d5;
}
11 changes: 10 additions & 1 deletion demo-ng/app/item/items.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
</ActionBar>

<StackLayout class="page">
<Button text="login" (tap)="login()"></Button>
<Label text="Authentication" class="h2"></Label>
<Button text="login anonymously" (tap)="loginAnonymously()" class="button button-user"></Button>
<Label text="Firestore" class="h2"></Label>
<Button text="Add" (tap)="firestoreAdd()" class="button"></Button>
<Button text="Set" (tap)="firestoreSet()" class="button"></Button>
<Button text="Set (auto id)" (tap)="firestoreSetByAutoID()" class="button"></Button>
<Button text="Update" (tap)="firestoreUpdate()" class="button"></Button>
<Button text="Get" (tap)="firestoreGet()" class="button"></Button>
<Button text="Delete" (tap)="firestoreDelete()" class="button"></Button>

</StackLayout>
63 changes: 60 additions & 3 deletions demo-ng/app/item/items.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Component, OnInit } from "@angular/core";
import { firestore } from "nativescript-plugin-firebase";
// import { firestore } from "nativescript-plugin-firebase/app/firestore";

const firebase = require("nativescript-plugin-firebase/app");

@Component({
Expand All @@ -15,10 +18,64 @@ export class ItemsComponent implements OnInit {
firebase.initializeApp();
}

public login(): void {
console.log(">>> login");
public loginAnonymously(): void {
firebase.auth().signInAnonymously()
.then(() => console.log("Logged in"))
.catch(err => console.log("Login error: " + err));
.catch(err => console.log("Login error: " + JSON.stringify(err)));
}

public firestoreAdd(): void {
firebase.firestore().collection("dogs").add({name: "Fido"})
.then((docRef: firestore.DocumentReference) => {
console.log("Fido added, ref: " + docRef.id);
})
.catch(err => console.log("Adding Fido failed, error: " + err));
}

public firestoreSet(): void {
firebase.firestore().collection("dogs").doc("fave")
.set({name: "Woofie", last: "lastofwoofie", date: new Date()}, {merge: true})
.then(() => {
console.log("Woofie set");
})
.catch(err => console.log("Setting Woofie failed, error: " + err));
}

public firestoreSetByAutoID(): void {
firebase.firestore().collection("dogs").doc()
.set({name: "Woofie", last: "lastofwoofie", date: new Date()})
.then(() => {
console.log("Woofie set");
})
.catch(err => console.log("Setting Woofie failed, error: " + err));
}

public firestoreUpdate(): void {
firebase.firestore().collection("dogs").doc("fave")
.update({name: "Woofieupdate", last: "updatedwoofie"})
.then(() => {
console.log("Woofie updated");
})
.catch(err => console.log("Updating Woofie failed, error: " + JSON.stringify(err)));
}

public firestoreGet(): void {
const collectionRef: firestore.CollectionReference = firebase.firestore().collection("dogs");
collectionRef.get()
.then((querySnapshot: firestore.QuerySnapshot) => {
querySnapshot.forEach(doc => {
console.log(`${doc.id} => ${JSON.stringify(doc.data())}`);
});
})
.catch(err => console.log("Get failed, error" + err));
}

public firestoreDelete(): void {
firebase.firestore().collection("dogs").doc("fave")
.delete()
.then(() => {
console.log("Woofie deleted");
})
.catch(err => console.log("Delete failed, error" + err));
}
}
2 changes: 1 addition & 1 deletion demo-ng/app/main.aot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { platformNativeScript } from "nativescript-angular/platform-static";

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

const firebase = require("nativescript-plugin-firebase");
require("nativescript-plugin-firebase");

platformNativeScript().bootstrapModuleFactory(AppModuleNgFactory);
2 changes: 1 addition & 1 deletion demo-ng/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { platformNativeScriptDynamic } from "nativescript-angular/platform";

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

const firebase = require("nativescript-plugin-firebase");
require("nativescript-plugin-firebase");

// A traditional NativeScript application starts by initializing global objects, setting up global CSS rules, creating, and navigating to the main page.
// Angular applications need to take care of their own initialization: modules, components, directives, routes, DI providers.
Expand Down
1 change: 1 addition & 0 deletions demo-ng/firebase.nativescript.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"using_ios": true,
"using_android": true,
"firestore": true,
"remote_config": true,
"messaging": true,
"crash_reporting": true,
Expand Down
Loading

0 comments on commit 872a004

Please sign in to comment.