Skip to content

Send push notifications to users nearby unrated locations#688

Open
M4ttoF wants to merge 2 commits intohhaccessibility:masterfrom
M4ttoF:push-notif
Open

Send push notifications to users nearby unrated locations#688
M4ttoF wants to merge 2 commits intohhaccessibility:masterfrom
M4ttoF:push-notif

Conversation

@M4ttoF
Copy link
Copy Markdown
Collaborator

@M4ttoF M4ttoF commented Aug 22, 2018

Will ask users to rate locations if they are within 20 meters of them hourly.
Line 88 in "service-worker.js" sends a sample push notification after 5 seconds for testing purposes. Tester must be near an unrated location for this to work. This line can be removed after testing has succeeded.
Addresses #638

…of an unrated location. New notifications will replace old ones to avoid spam. Mobile users will get a vibration and noise when receiving it
Comment thread app/public/service-worker.js Outdated
})

self.addEventListener('fetch',function(e) {
//console.log('fetching '+e);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this code that doesn't do anything. The fetch here doesn't do anything. I guess you used it for troubleshooting but it doesn't need to get deployed.

@@ -0,0 +1,50 @@
var url= window.location.href;
var pos = url.search('using_pwa');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this check to the server. HomeController.php has a method that would be called for route "/". Store the true/false value of whether the request was using_pwa into the server's session so it is available as the user navigates around the site.

This value on the server can be used to prevent including these service worker scripts when not in a PWA.

Comment thread app/public/js/home.js
default_location = new google.maps.LatLng(default_location.latitude, default_location.longitude);

try{
default_location = new google.maps.LatLng(default_location.latitude, default_location.longitude);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When was this needed? What error did you run into? Was default_location.latitude undefined at some point?

Comment thread app/public/service-worker.js Outdated
reviewRedirect='location/rating/'+id+'/5';
options.body='Would you like to add a review to '+name+'?';
}
//self.registration.showNotification(title, options);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does helpNotification do anything after the showNotification was commented out?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it will be used to update the data based on the new user locations. I'll rename the methods to clear up the confusion since they've changed from what I originally intended when making them

Comment thread app/public/service-worker.js Outdated
options = {
body: '',
icon: '/images/logo-192x192.png',
sound: '/sounds/alert.wav',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget to commit this public/sounds/alert.wav file?

Also, is it big? mp3 may be better compressed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must've lost it when I was fixing rebase issues, I'll add it back and change it to an mp3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants