瀏覽代碼

Only register permission once

Sebastián Katzer 10 年之前
父節點
當前提交
731ac9dfa7
共有 2 個文件被更改,包括 10 次插入0 次删除
  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 *