Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notificaion removed in score #939

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions public/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,37 @@ self.addEventListener("notificationclick", function (e) {
});

self.addEventListener("push", async function (e) {
try {

var data = e.data.json();

// var options = {
// body: body,
// icon: "/mstile-150x150.png",
// image: "",
// vibrate: [100, 50, 100],
// sound: "clip",
// data: {
// dateOfArrival: Date.now(),
// primaryKey: 1,
// },
// actions: [
// {
// action: "explore",
// title: "Explore this new world",

// },
// {
// action: "close",
// title: "I don't want any of this",

// },
// ],
// };
e.waitUntil(self.registration.showNotification(data.data.title, e.data.json()));
var data = e.data.json();

// var options = {
// body: body,
// icon: "/mstile-150x150.png",
// image: "",
// vibrate: [100, 50, 100],
// sound: "clip",
// data: {
// dateOfArrival: Date.now(),
// primaryKey: 1,
// },
// actions: [
// {
// action: "explore",
// title: "Explore this new world",

// },
// {
// action: "close",
// title: "I don't want any of this",

// },
// ],
// };
e.waitUntil(self.registration.showNotification(data.data.title, e.data.json()));
} catch (e) {
return;
}
});

},{}]},{},[1]);
42 changes: 24 additions & 18 deletions src/components/participant/ActionInputs/PushNotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default {
};
},
mounted() {

if (this.$route.query) {
if (this.$route.query.subsId === localStorage.getItem("subsId")) {
this.data.value = "Subscribed";
Expand All @@ -103,31 +104,36 @@ export default {
methods: {
async giveScore() {
if (!this.isFieldValid()) {
this.data.value = "";
this.data.subObj = "";
return this.notifyErr(Messages.EVENT_ACTIONS.INVALID_INPUT);
} else {
this.data.value="Subscribed"
this.$emit("input", this.data.value);
}
},
async update() {
if(localStorage.getItem("subsId")!==undefined){
const response = await fetch(
config.studioServer.BASE_URL + "api/v1/push/verifyNotification",
{
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("authToken")}`,
},
body: JSON.stringify({
subObj: this.data.subObj,
id: this.data.subscription._id,
url: location.href,
}),
}
);
return response.json();
// if(localStorage.getItem("subsId")!==undefined){
// const response = await fetch(
// config.studioServer.BASE_URL + "api/v1/push/verifyNotification",
// {
// method: "post",
// headers: {
// "Content-Type": "application/json",
// Authorization: `Bearer ${localStorage.getItem("authToken")}`,
// },
// body: JSON.stringify({
// subObj: this.data.subObj,
// id: this.data.subscription._id,
// url: location.href,
// }),
// }
// );
// return response.json();
if(this.data.subObj !==undefined && this.data.subscription!==undefined){
this.data.value="Notificaion Subscribed"
this.$emit("input", this.data.value);
}

},
isFieldValid() {
if (isEmpty(this.data.value)) {
Expand Down
7 changes: 6 additions & 1 deletion src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ self.addEventListener("notificationclick", (e) => {
});

self.addEventListener("push", async function (e) {

try {


const data=e.data.json()

// var options = {
Expand Down Expand Up @@ -54,4 +56,7 @@ self.addEventListener("push", async function (e) {
e.waitUntil(
self.registration.showNotification(data.data.title, e.data.json())
);
}catch(e){
return
}
});