Fix db path; add new pathing for web-push; load VAPID at boot
This commit is contained in:
22
src/App.vue
22
src/App.vue
@@ -261,9 +261,24 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Vue, Component } from "vue-facing-decorator";
|
import { Vue, Component } from "vue-facing-decorator";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class App extends Vue {
|
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> {
|
private askPermission(): Promise<NotificationPermission> {
|
||||||
// Check if Notifications are supported
|
// Check if Notifications are supported
|
||||||
if (!("Notification" in window)) {
|
if (!("Notification" in window)) {
|
||||||
@@ -355,12 +370,9 @@ export default class App extends Vue {
|
|||||||
private subscribeToPush(): Promise<void> {
|
private subscribeToPush(): Promise<void> {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
if ("serviceWorker" in navigator && "PushManager" in window) {
|
if ("serviceWorker" in navigator && "PushManager" in window) {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker.ready
|
||||||
.register("/service-worker.js")
|
|
||||||
.then((registration) => {
|
.then((registration) => {
|
||||||
const b64 =
|
const applicationServerKey = this.urlBase64ToUint8Array(this.b64);
|
||||||
"BEl62iUYgUivxIkv69yViEuiBIa-Ib9-SkvMeAtA3LFgDzkrxZJjSgSnfckjBJuBkr3qBUYIHBQFLXYp5Nksh8U";
|
|
||||||
const applicationServerKey = this.urlBase64ToUint8Array(b64);
|
|
||||||
|
|
||||||
const options: PushSubscriptionOptions = {
|
const options: PushSubscriptionOptions = {
|
||||||
userVisibleOnly: true,
|
userVisibleOnly: true,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Generic strings that could be used throughout the app.
|
* Generic strings that could be used throughout the app.
|
||||||
*/
|
*/
|
||||||
export enum AppString {
|
export enum AppString {
|
||||||
APP_NAME = "Kick-Start with Time",
|
APP_NAME = "TimeSafari",
|
||||||
|
|
||||||
PROD_ENDORSER_API_SERVER = "https://api.endorser.ch",
|
PROD_ENDORSER_API_SERVER = "https://api.endorser.ch",
|
||||||
TEST_ENDORSER_API_SERVER = "https://test-api.endorser.ch",
|
TEST_ENDORSER_API_SERVER = "https://test-api.endorser.ch",
|
||||||
|
|||||||
Reference in New Issue
Block a user