Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Use push server DELETE route to remove browser keys
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Jul 22, 2016
1 parent efdef52 commit 4615ea6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/browser/ServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ self.addEventListener('push', function(event) {
// Need to figure out a way to make these configurable
var title = obj.title || 'Default title';
var body = obj.body || 'This is the default body';
var icon = 'https://avatars1.githubusercontent.com/u/60365?v=3&s=200';
var icon = obj.image || 'https://avatars1.githubusercontent.com/u/60365?v=3&s=200';
var tag = 'simple-push-demo-notification-tag';

event.waitUntil(
Expand Down
12 changes: 5 additions & 7 deletions www/browser/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ PushNotification.prototype.unregister = function(successCallback, errorCallback,

serviceWorker.unregister().then(function(isSuccess) {
if (isSuccess) {
var deviceID = subscription.endpoint.substring(subscription.endpoint.lastIndexOf('/') + 1);
var xmlHttp = new XMLHttpRequest();
var xmlURL = (that.options.browser.pushServiceURL || 'http://push.api.phonegap.com/v1/push') + '/keys/remove';
xmlHttp.open('POST', xmlURL, true);

var formData = new FormData();
formData.append('subscription', JSON.stringify(subscription));

xmlHttp.send(formData);
var xmlURL = (that.options.browser.pushServiceURL || 'http://push.api.phonegap.com/v1/push')
+ '/keys/' + deviceID;
xmlHttp.open('DELETE', xmlURL, true);
xmlHttp.send();

successCallback();
} else {
Expand Down

0 comments on commit 4615ea6

Please sign in to comment.