local-notification.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. /*
  2. * This file contains Original Code and/or Modifications of Original Code
  3. * as defined in and that are subject to the Apache License
  4. * Version 2.0 (the 'License'). You may not use this file except in
  5. * compliance with the License. Please obtain a copy of the License at
  6. * http://opensource.org/licenses/Apache-2.0/ and read it before using this
  7. * file.
  8. *
  9. * The Original Code and all software distributed under the License are
  10. * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  11. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  12. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  13. * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  14. * Please see the License for the specific language governing rights and
  15. * limitations under the License.
  16. */
  17. /**
  18. * Request permission to show notifications.
  19. *
  20. * @param [ Function ] callback The function to be exec as the callback.
  21. * @param [ Object ] scope The callback function's scope.
  22. *
  23. * @return [ Void ]
  24. */
  25. exports.hasPermission = function (callback, scope) {
  26. this.core.hasPermission(callback, scope);
  27. };
  28. /**
  29. * Request permission to show notifications.
  30. *
  31. * @param [ Function ] callback The function to be exec as the callback.
  32. * @param [ Object ] scope The callback function's scope.
  33. *
  34. * @return [ Void ]
  35. */
  36. exports.requestPermission = function (callback, scope) {
  37. this.core.requestPermission(callback, scope);
  38. };
  39. // /**
  40. // * Returns the default settings.
  41. // *
  42. // * @return {Object}
  43. // */
  44. // exports.getDefaults = function () {
  45. // return this.core.getDefaults();
  46. // };
  47. // /**
  48. // * Overwrite default settings.
  49. // *
  50. // * @param {Object} defaults
  51. // */
  52. // exports.setDefaults = function (defaults) {
  53. // this.core.setDefaults(defaults);
  54. // };
  55. // /**
  56. // * Schedule a new local notification.
  57. // *
  58. // * @param {Object} notifications
  59. // * The notification properties
  60. // * @param {Function} callback
  61. // * A function to be called after the notification has been canceled
  62. // * @param {Object?} scope
  63. // * The scope for the callback function
  64. // * @param {Object?} args
  65. // * skipPermission:true schedules the notifications immediatly without
  66. // * registering or checking for permission
  67. // */
  68. // exports.schedule = function (notifications, callback, scope, args) {
  69. // this.core.schedule(notifications, callback, scope, args);
  70. // };
  71. // /**
  72. // * Update existing notifications specified by IDs in options.
  73. // *
  74. // * @param {Object} notifications
  75. // * The notification properties to update
  76. // * @param {Function} callback
  77. // * A function to be called after the notification has been updated
  78. // * @param {Object?} scope
  79. // * The scope for the callback function
  80. // * @param {Object?} args
  81. // * skipPermission:true schedules the notifications immediatly without
  82. // * registering or checking for permission
  83. // */
  84. // exports.update = function (notifications, callback, scope, args) {
  85. // this.core.update(notifications, callback, scope, args);
  86. // };
  87. // /**
  88. // * Clear the specified notification.
  89. // *
  90. // * @param {String} id
  91. // * The ID of the notification
  92. // * @param {Function} callback
  93. // * A function to be called after the notification has been cleared
  94. // * @param {Object?} scope
  95. // * The scope for the callback function
  96. // */
  97. // exports.clear = function (ids, callback, scope) {
  98. // this.core.clear(ids, callback, scope);
  99. // };
  100. // /**
  101. // * Clear all previously sheduled notifications.
  102. // *
  103. // * @param {Function} callback
  104. // * A function to be called after all notifications have been cleared
  105. // * @param {Object?} scope
  106. // * The scope for the callback function
  107. // */
  108. // exports.clearAll = function (callback, scope) {
  109. // this.core.clearAll(callback, scope);
  110. // };
  111. // /**
  112. // * Cancel the specified notifications.
  113. // *
  114. // * @param {String[]} ids
  115. // * The IDs of the notifications
  116. // * @param {Function} callback
  117. // * A function to be called after the notifications has been canceled
  118. // * @param {Object?} scope
  119. // * The scope for the callback function
  120. // */
  121. // exports.cancel = function (ids, callback, scope) {
  122. // this.core.cancel(ids, callback, scope);
  123. // };
  124. // /**
  125. // * Remove all previously registered notifications.
  126. // *
  127. // * @param {Function} callback
  128. // * A function to be called after all notifications have been canceled
  129. // * @param {Object?} scope
  130. // * The scope for the callback function
  131. // */
  132. // exports.cancelAll = function (callback, scope) {
  133. // this.core.cancelAll(callback, scope);
  134. // };
  135. // /**
  136. // * Check if a notification with an ID is present.
  137. // *
  138. // * @param {String} id
  139. // * The ID of the notification
  140. // * @param {Function} callback
  141. // * A callback function to be called with the list
  142. // * @param {Object?} scope
  143. // * The scope for the callback function
  144. // */
  145. // exports.isPresent = function (id, callback, scope) {
  146. // this.core.isPresent(id, callback, scope);
  147. // };
  148. // /**
  149. // * Check if a notification with an ID is scheduled.
  150. // *
  151. // * @param {String} id
  152. // * The ID of the notification
  153. // * @param {Function} callback
  154. // * A callback function to be called with the list
  155. // * @param {Object?} scope
  156. // * The scope for the callback function
  157. // */
  158. // exports.isScheduled = function (id, callback, scope) {
  159. // this.core.isScheduled(id, callback, scope);
  160. // };
  161. // *
  162. // * Check if a notification with an ID was triggered.
  163. // *
  164. // * @param {String} id
  165. // * The ID of the notification
  166. // * @param {Function} callback
  167. // * A callback function to be called with the list
  168. // * @param {Object?} scope
  169. // * The scope for the callback function
  170. // exports.isTriggered = function (id, callback, scope) {
  171. // this.core.isTriggered(id, callback, scope);
  172. // };
  173. // /**
  174. // * List all local notification IDs.
  175. // *
  176. // * @param {Function} callback
  177. // * A callback function to be called with the list
  178. // * @param {Object?} scope
  179. // * The scope for the callback function
  180. // */
  181. // exports.getAllIds = function (callback, scope) {
  182. // this.core.getAllIds(callback, scope);
  183. // };
  184. // /**
  185. // * Alias for `getAllIds`.
  186. // */
  187. // exports.getIds = function () {
  188. // this.getAllIds.apply(this, arguments);
  189. // };
  190. // /**
  191. // * List all scheduled notification IDs.
  192. // *
  193. // * @param {Function} callback
  194. // * A callback function to be called with the list
  195. // * @param {Object?} scope
  196. // * The scope for the callback function
  197. // */
  198. // exports.getScheduledIds = function (callback, scope) {
  199. // this.core.getScheduledIds(callback, scope);
  200. // };
  201. // /**
  202. // * List all triggered notification IDs.
  203. // *
  204. // * @param {Function} callback
  205. // * A callback function to be called with the list
  206. // * @param {Object?} scope
  207. // * The scope for the callback function
  208. // */
  209. // exports.getTriggeredIds = function (callback, scope) {
  210. // this.core.getTriggeredIds(callback, scope);
  211. // };
  212. // /**
  213. // * Property list for given local notifications.
  214. // * If called without IDs, all notification will be returned.
  215. // *
  216. // * @param {Number[]?} ids
  217. // * Set of notification IDs
  218. // * @param {Function} callback
  219. // * A callback function to be called with the list
  220. // * @param {Object?} scope
  221. // * The scope for the callback function
  222. // */
  223. // exports.get = function () {
  224. // this.core.get.apply(this.core, arguments);
  225. // };
  226. // /**
  227. // * Property list for all local notifications.
  228. // *
  229. // * @param {Function} callback
  230. // * A callback function to be called with the list
  231. // * @param {Object?} scope
  232. // * The scope for the callback function
  233. // */
  234. // exports.getAll = function (callback, scope) {
  235. // this.core.getAll(callback, scope);
  236. // };
  237. // /**
  238. // * Property list for given scheduled notifications.
  239. // * If called without IDs, all notification will be returned.
  240. // *
  241. // * @param {Number[]?} ids
  242. // * Set of notification IDs
  243. // * @param {Function} callback
  244. // * A callback function to be called with the list
  245. // * @param {Object?} scope
  246. // * The scope for the callback function
  247. // */
  248. // exports.getScheduled = function () {
  249. // this.core.getScheduled.apply(this.core, arguments);
  250. // };
  251. // /**
  252. // * Property list for all scheduled notifications.
  253. // *
  254. // * @param {Function} callback
  255. // * A callback function to be called with the list
  256. // * @param {Object?} scope
  257. // * The scope for the callback function
  258. // */
  259. // exports.getAllScheduled = function (callback, scope) {
  260. // this.core.getAllScheduled(callback, scope);
  261. // };
  262. // /**
  263. // * Property list for given triggered notifications.
  264. // * If called without IDs, all notification will be returned.
  265. // *
  266. // * @param {Number[]?} ids
  267. // * Set of notification IDs
  268. // * @param {Function} callback
  269. // * A callback function to be called with the list
  270. // * @param {Object?} scope
  271. // * The scope for the callback function
  272. // */
  273. // exports.getTriggered = function () {
  274. // this.core.getTriggered.apply(this.core, arguments);
  275. // };
  276. // /**
  277. // * Property list for all triggered notifications.
  278. // *
  279. // * @param {Function} callback
  280. // * A callback function to be called with the list
  281. // * @param {Object?} scope
  282. // * The scope for the callback function
  283. // */
  284. // exports.getAllTriggered = function (callback, scope) {
  285. // this.core.getAllTriggered(callback, scope);
  286. // };
  287. // /**
  288. // * Register callback for given event.
  289. // *
  290. // * @param {String} event
  291. // * The event's name
  292. // * @param {Function} callback
  293. // * The function to be exec as callback
  294. // * @param {Object?} scope
  295. // * The callback function's scope
  296. // */
  297. // exports.on = function (event, callback, scope) {
  298. // this.core.on(event, callback, scope);
  299. // };
  300. // /**
  301. // * Unregister callback for given event.
  302. // *
  303. // * @param {String} event
  304. // * The event's name
  305. // * @param {Function} callback
  306. // * The function to be exec as callback
  307. // */
  308. // exports.un = function (event, callback) {
  309. // this.core.un(event, callback);
  310. // };