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

Commit

Permalink
🐛 Issue #1412: push.subscribe 'not a function' error
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Nov 28, 2016
1 parent dce845f commit 1c0c0bc
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions www/browser/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,52 @@ PushNotification.prototype.unregister = function(successCallback, errorCallback,
}
};

/**
* subscribe to a topic
* @param {String} topic topic to subscribe
* @param {Function} successCallback success callback
* @param {Function} errorCallback error callback
* @return {void}
*/
PushNotification.prototype.subscribe = function(topic, successCallback, errorCallback) {
if (!errorCallback) { errorCallback = function() {}; }

if (typeof errorCallback !== 'function') {
console.log('PushNotification.subscribe failure: failure parameter not a function');
return;
}

if (typeof successCallback !== 'function') {
console.log('PushNotification.subscribe failure: success callback parameter must be a function');
return;
}

successCallback();
};

/**
* unsubscribe to a topic
* @param {String} topic topic to unsubscribe
* @param {Function} successCallback success callback
* @param {Function} errorCallback error callback
* @return {void}
*/
PushNotification.prototype.unsubscribe = function(topic, successCallback, errorCallback) {
if (!errorCallback) { errorCallback = function() {}; }

if (typeof errorCallback !== 'function') {
console.log('PushNotification.unsubscribe failure: failure parameter not a function');
return;
}

if (typeof successCallback !== 'function') {
console.log('PushNotification.unsubscribe failure: success callback parameter must be a function');
return;
}

successCallback();
};

/**
* Call this to set the application icon badge
*/
Expand Down

0 comments on commit 1c0c0bc

Please sign in to comment.