Browse Source

Debugging and ironing out the flow

kb/add-usage-guide
Matthew Raymer 1 year ago
parent
commit
2eaa4203aa
  1. 7
      src/App.vue

7
src/App.vue

@ -267,7 +267,6 @@ import axios from "axios";
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) => {
@ -372,12 +371,14 @@ export default class App extends Vue {
if ("serviceWorker" in navigator && "PushManager" in window) {
navigator.serviceWorker.ready
.then((registration) => {
console.log(this.b64);
const applicationServerKey = this.urlBase64ToUint8Array(this.b64);
const options: PushSubscriptionOptions = {
userVisibleOnly: true,
applicationServerKey: applicationServerKey,
};
console.log(options);
return registration.pushManager.subscribe(options);
})
@ -400,8 +401,8 @@ export default class App extends Vue {
private sendSubscriptionToServer(
subscription: PushSubscription,
): Promise<void> {
// Simulated API call
return fetch("/api/save-subscription", {
console.log(subscription);
return fetch("/web-push/subscribe", {
method: "POST",
headers: {
"Content-Type": "application/json",

Loading…
Cancel
Save