|
@ -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, |
|
|