-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pushAndroid' into 'development'
Push Notification For Android See merge request lappis-unb/projects/SMI/smi-mobile!17
- Loading branch information
Showing
25 changed files
with
406 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
API_KEY=api_key | ||
AUTH_DOMAIN=auth_domain | ||
DATABASE_URL=database_url | ||
PROJECT_ID=project_id | ||
STORAGE_BUCKET=storage_bucket | ||
MESSAGE_SENDER_ID=message_sender_id | ||
APP_ID=app_id | ||
KEY_SERVER=key_server | ||
VAPID_KEY=public_vapid_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
importScripts('https://www.gstatic.com/firebasejs/7.7.0/firebase-app.js'); | ||
importScripts('https://www.gstatic.com/firebasejs/7.7.0/firebase-messaging.js'); | ||
importScripts('env-sw.js'); | ||
|
||
var firebaseConfig = { | ||
apiKey: process.env.API_KEY, | ||
authDomain: process.env.AUTH_DOMAIN, | ||
databaseURL: process.env.DATABASE_URL, | ||
projectId: process.env.PROJECT_ID, | ||
storageBucket: process.env.STORAGE_BUCKET, | ||
messagingSenderId: process.env.MESSAGE_SENDER_ID, | ||
appId: process.env.APP_ID | ||
}; | ||
|
||
firebase.initializeApp(firebaseConfig); | ||
|
||
if (firebase.messaging.isSupported()) { | ||
|
||
const messaging = firebase.messaging(); | ||
|
||
} | ||
|
||
// if event listener receive a notification object in background it show more than one push | ||
self.addEventListener('push', function(event) { | ||
//console.log('[Service Worker] Push Received.'); | ||
//console.log('[Service Worker] Push had this data:', event.data.json()); | ||
|
||
const title = event.data.json().data['title']; | ||
const options = { | ||
body: event.data.json().data['body'], | ||
icon: '/statics/icons/icon-512x512.png', | ||
badge: '/statics/icons/notification-96x96.png', | ||
vibrate: [100,50,100] | ||
}; | ||
|
||
event.waitUntil(self.registration.showNotification(title, options)); | ||
}); | ||
|
||
|
||
self.addEventListener('notificationclick', function(event) { | ||
event.notification.close(); | ||
clients.openWindow("/"); | ||
//handle click event onClick on Web Push Notification | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as firebase from 'firebase/app' | ||
import 'firebase/messaging' | ||
|
||
export default ({ Vue }) => { | ||
var config = { | ||
apiKey: process.env.API_KEY, | ||
authDomain: process.env.AUTH_DOMAIN, | ||
databaseURL: process.env.DATABASE_URL, | ||
projectId: process.env.PROJECT_ID, | ||
storageBucket: process.env.STORAGE_BUCKET, | ||
messagingSenderId: process.env.MESSAGE_SENDER_ID, | ||
appId: process.env.APP_ID | ||
} | ||
|
||
firebase.initializeApp(config) | ||
|
||
Vue.prototype.$firebase = firebase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Cookies } from 'quasar' | ||
import createPersistedState from 'vuex-persistedstate' | ||
|
||
export default function ({ store, ssrContext }) { | ||
const cookies = process.env.SERVER | ||
? Cookies.parseSSR(ssrContext) | ||
: Cookies | ||
|
||
createPersistedState({ | ||
key: 'storedData', | ||
paths: ['storedData'], | ||
filter ({ type }) { | ||
return type.startsWith('storedData') | ||
}, | ||
storage: { | ||
getItem (key) { | ||
return JSON.stringify(cookies.get(key)) | ||
}, | ||
setItem (key, value) { | ||
cookies.set(key, value, { path: '/' }) | ||
}, | ||
removeItem (key) { | ||
cookies.remove(key) | ||
} | ||
} | ||
})(store) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.