Browse Source

Fix db path; add new pathing for web-push; load VAPID at boot

kb/add-usage-guide
Matthew Raymer 1 year ago
parent
commit
f27a18c712
  1. 22
      src/App.vue
  2. 2
      src/constants/app.ts

22
src/App.vue

@ -261,9 +261,24 @@
<script lang="ts">
import { Vue, Component } from "vue-facing-decorator";
import axios from "axios";
@Component
export default class App extends Vue {
b64 = "";
mounted() {
// Your API call logic here
axios
.get("https://timesafari-pwa.anomalistlabs.com/web-push/vapid")
.then((response) => {
this.b64 = response.data.vapidKey;
console.log(this.b64);
})
.catch((error) => {
console.error("API error", error);
});
}
private askPermission(): Promise<NotificationPermission> {
// Check if Notifications are supported
if (!("Notification" in window)) {
@ -355,12 +370,9 @@ export default class App extends Vue {
private subscribeToPush(): Promise<void> {
return new Promise<void>((resolve, reject) => {
if ("serviceWorker" in navigator && "PushManager" in window) {
navigator.serviceWorker
.register("/service-worker.js")
navigator.serviceWorker.ready
.then((registration) => {
const b64 =
"BEl62iUYgUivxIkv69yViEuiBIa-Ib9-SkvMeAtA3LFgDzkrxZJjSgSnfckjBJuBkr3qBUYIHBQFLXYp5Nksh8U";
const applicationServerKey = this.urlBase64ToUint8Array(b64);
const applicationServerKey = this.urlBase64ToUint8Array(this.b64);
const options: PushSubscriptionOptions = {
userVisibleOnly: true,

2
src/constants/app.ts

@ -2,7 +2,7 @@
* Generic strings that could be used throughout the app.
*/
export enum AppString {
APP_NAME = "Kick-Start with Time",
APP_NAME = "TimeSafari",
PROD_ENDORSER_API_SERVER = "https://api.endorser.ch",
TEST_ENDORSER_API_SERVER = "https://test-api.endorser.ch",

Loading…
Cancel
Save