Bladeren bron

Only register permission once

Sebastián Katzer 10 jaren geleden
bovenliggende
commit
731ac9dfa7
2 gewijzigde bestanden met toevoegingen van 10 en 0 verwijderingen
  1. 7 0
      www/local-notification-core.js
  2. 3 0
      www/local-notification-util.js

+ 7 - 0
www/local-notification-core.js

@@ -414,6 +414,13 @@ exports.hasPermission = function (callback, scope) {
  *      The callback function's scope
  */
 exports.registerPermission = function (callback, scope) {
+
+    if (this._registered) {
+        return this.hasPermission(callback, scope);
+    } else {
+        this._registered = true;
+    }
+
     var fn = this.createCallbackFn(callback, scope);
 
     if (device.platform != 'iOS') {

+ 3 - 0
www/local-notification-util.js

@@ -44,6 +44,9 @@ exports._defaults = {
 // listener
 exports._listener = {};
 
+// Registered permission flag
+exports._registered = false;
+
 
 /********
  * UTIL *