Skip to content

Commit

Permalink
Can poke a hardcoded wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
vince0656 committed Nov 26, 2019
1 parent 75b5ac7 commit b74b582
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# General
src/_config/
.firebase/

.DS_Store
node_modules
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"http2": "^3.3.7",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vue-uuid": "^1.1.1",
"vuex": "^3.0.1"
},
"devDependencies": {
Expand Down
9 changes: 1 addition & 8 deletions src/Firebase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ const {firebaseConfig} = require('../_config/env');

firebase.initializeApp(firebaseConfig);

const admin = require('firebase-admin');
admin.initializeApp({
credential: admin.credential.cert(require('../_config/sdk-keys')),
databaseURL: 'https://alice-1555232535074.firebaseio.com'
});

module.exports = {
db: firebase.firestore(),
messaging: firebase.messaging(),
admin
messaging: firebase.messaging()
};
22 changes: 10 additions & 12 deletions src/components/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script>
import {ethers} from "ethers";
import Accounts from '@/Firebase/Accounts';
import {messaging, admin} from '@/Firebase/index';
import {db, messaging} from '@/Firebase/index';
import env from '@/_config/env';
messaging.usePublicVapidKey(env.messaging.publicVapidKey);
Expand Down Expand Up @@ -44,17 +44,15 @@
.then(currentToken => this.onFCMTokenReceived(currentToken))
.catch((err) => console.log('An error occurred while retrieving token. ', err));
},
poke: async function () {
const firebaseMessagingToken = Accounts.getFirebaseMessagingTokenForAccount(this.accounts.user);
console.log('firebaseMessagingToken', firebaseMessagingToken);
const payload = {
token: firebaseMessagingToken,
notification: {
title: "Poke alert",
body: "lolz",
}
};
return admin.messaging().send(payload);
poke: function () {
const pokeId = this.$uuid.v4();
db.collection('wizards').doc('network').collection('rinkeby').doc('293')
.collection('poke')
.doc(pokeId)
.set({msg: 'ullo'}, {
merge: true
});
console.log(`poke!! ${pokeId}`);
}
},
async mounted() {
Expand Down
7 changes: 5 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import UUID from 'vue-uuid';

Vue.config.productionTip = false
Vue.use(UUID);

Vue.config.productionTip = false;

new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
}).$mount('#app');

0 comments on commit b74b582

Please sign in to comment.