local-notification.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. * Schedule notifications.
  41. *
  42. * @param [ Array ] notifications The notifications to schedule.
  43. * @param [ Function ] callback The function to be exec as the callback.
  44. * @param [ Object ] scope The callback function's scope.
  45. * @param [ Object ] args Optional flags how to schedule.
  46. *
  47. * @return [ Void ]
  48. */
  49. exports.schedule = function (notifications, callback, scope, args) {
  50. this.core.schedule(notifications, callback, scope, args);
  51. };
  52. // /**
  53. // * Update existing notifications specified by IDs in options.
  54. // *
  55. // * @param {Object} notifications
  56. // * The notification properties to update
  57. // * @param {Function} callback
  58. // * A function to be called after the notification has been updated
  59. // * @param {Object?} scope
  60. // * The scope for the callback function
  61. // * @param {Object?} args
  62. // * skipPermission:true schedules the notifications immediatly without
  63. // * registering or checking for permission
  64. // */
  65. // exports.update = function (notifications, callback, scope, args) {
  66. // this.core.update(notifications, callback, scope, args);
  67. // };
  68. // /**
  69. // * Clear the specified notification.
  70. // *
  71. // * @param {String} id
  72. // * The ID of the notification
  73. // * @param {Function} callback
  74. // * A function to be called after the notification has been cleared
  75. // * @param {Object?} scope
  76. // * The scope for the callback function
  77. // */
  78. // exports.clear = function (ids, callback, scope) {
  79. // this.core.clear(ids, callback, scope);
  80. // };
  81. // /**
  82. // * Clear all previously sheduled notifications.
  83. // *
  84. // * @param {Function} callback
  85. // * A function to be called after all notifications have been cleared
  86. // * @param {Object?} scope
  87. // * The scope for the callback function
  88. // */
  89. // exports.clearAll = function (callback, scope) {
  90. // this.core.clearAll(callback, scope);
  91. // };
  92. // /**
  93. // * Cancel the specified notifications.
  94. // *
  95. // * @param {String[]} ids
  96. // * The IDs of the notifications
  97. // * @param {Function} callback
  98. // * A function to be called after the notifications has been canceled
  99. // * @param {Object?} scope
  100. // * The scope for the callback function
  101. // */
  102. // exports.cancel = function (ids, callback, scope) {
  103. // this.core.cancel(ids, callback, scope);
  104. // };
  105. // /**
  106. // * Remove all previously registered notifications.
  107. // *
  108. // * @param {Function} callback
  109. // * A function to be called after all notifications have been canceled
  110. // * @param {Object?} scope
  111. // * The scope for the callback function
  112. // */
  113. // exports.cancelAll = function (callback, scope) {
  114. // this.core.cancelAll(callback, scope);
  115. // };
  116. // /**
  117. // * Check if a notification with an ID is present.
  118. // *
  119. // * @param {String} id
  120. // * The ID of the notification
  121. // * @param {Function} callback
  122. // * A callback function to be called with the list
  123. // * @param {Object?} scope
  124. // * The scope for the callback function
  125. // */
  126. // exports.isPresent = function (id, callback, scope) {
  127. // this.core.isPresent(id, callback, scope);
  128. // };
  129. // /**
  130. // * Check if a notification with an ID is scheduled.
  131. // *
  132. // * @param {String} id
  133. // * The ID of the notification
  134. // * @param {Function} callback
  135. // * A callback function to be called with the list
  136. // * @param {Object?} scope
  137. // * The scope for the callback function
  138. // */
  139. // exports.isScheduled = function (id, callback, scope) {
  140. // this.core.isScheduled(id, callback, scope);
  141. // };
  142. // *
  143. // * Check if a notification with an ID was triggered.
  144. // *
  145. // * @param {String} id
  146. // * The ID of the notification
  147. // * @param {Function} callback
  148. // * A callback function to be called with the list
  149. // * @param {Object?} scope
  150. // * The scope for the callback function
  151. // exports.isTriggered = function (id, callback, scope) {
  152. // this.core.isTriggered(id, callback, scope);
  153. // };
  154. // /**
  155. // * List all local notification IDs.
  156. // *
  157. // * @param {Function} callback
  158. // * A callback function to be called with the list
  159. // * @param {Object?} scope
  160. // * The scope for the callback function
  161. // */
  162. // exports.getAllIds = function (callback, scope) {
  163. // this.core.getAllIds(callback, scope);
  164. // };
  165. // /**
  166. // * Alias for `getAllIds`.
  167. // */
  168. // exports.getIds = function () {
  169. // this.getAllIds.apply(this, arguments);
  170. // };
  171. // /**
  172. // * List all scheduled notification IDs.
  173. // *
  174. // * @param {Function} callback
  175. // * A callback function to be called with the list
  176. // * @param {Object?} scope
  177. // * The scope for the callback function
  178. // */
  179. // exports.getScheduledIds = function (callback, scope) {
  180. // this.core.getScheduledIds(callback, scope);
  181. // };
  182. // /**
  183. // * List all triggered notification IDs.
  184. // *
  185. // * @param {Function} callback
  186. // * A callback function to be called with the list
  187. // * @param {Object?} scope
  188. // * The scope for the callback function
  189. // */
  190. // exports.getTriggeredIds = function (callback, scope) {
  191. // this.core.getTriggeredIds(callback, scope);
  192. // };
  193. // /**
  194. // * Property list for given local notifications.
  195. // * If called without IDs, all notification will be returned.
  196. // *
  197. // * @param {Number[]?} ids
  198. // * Set of notification IDs
  199. // * @param {Function} callback
  200. // * A callback function to be called with the list
  201. // * @param {Object?} scope
  202. // * The scope for the callback function
  203. // */
  204. // exports.get = function () {
  205. // this.core.get.apply(this.core, arguments);
  206. // };
  207. // /**
  208. // * Property list for all local notifications.
  209. // *
  210. // * @param {Function} callback
  211. // * A callback function to be called with the list
  212. // * @param {Object?} scope
  213. // * The scope for the callback function
  214. // */
  215. // exports.getAll = function (callback, scope) {
  216. // this.core.getAll(callback, scope);
  217. // };
  218. // /**
  219. // * Property list for given scheduled notifications.
  220. // * If called without IDs, all notification will be returned.
  221. // *
  222. // * @param {Number[]?} ids
  223. // * Set of notification IDs
  224. // * @param {Function} callback
  225. // * A callback function to be called with the list
  226. // * @param {Object?} scope
  227. // * The scope for the callback function
  228. // */
  229. // exports.getScheduled = function () {
  230. // this.core.getScheduled.apply(this.core, arguments);
  231. // };
  232. // /**
  233. // * Property list for all scheduled notifications.
  234. // *
  235. // * @param {Function} callback
  236. // * A callback function to be called with the list
  237. // * @param {Object?} scope
  238. // * The scope for the callback function
  239. // */
  240. // exports.getAllScheduled = function (callback, scope) {
  241. // this.core.getAllScheduled(callback, scope);
  242. // };
  243. // /**
  244. // * Property list for given triggered notifications.
  245. // * If called without IDs, all notification will be returned.
  246. // *
  247. // * @param {Number[]?} ids
  248. // * Set of notification IDs
  249. // * @param {Function} callback
  250. // * A callback function to be called with the list
  251. // * @param {Object?} scope
  252. // * The scope for the callback function
  253. // */
  254. // exports.getTriggered = function () {
  255. // this.core.getTriggered.apply(this.core, arguments);
  256. // };
  257. // /**
  258. // * Property list for all triggered notifications.
  259. // *
  260. // * @param {Function} callback
  261. // * A callback function to be called with the list
  262. // * @param {Object?} scope
  263. // * The scope for the callback function
  264. // */
  265. // exports.getAllTriggered = function (callback, scope) {
  266. // this.core.getAllTriggered(callback, scope);
  267. // };
  268. /**
  269. * The (platform specific) default settings.
  270. *
  271. * @return [ Object ]
  272. */
  273. exports.getDefaults = function () {
  274. return this.core.getDefaults();
  275. };
  276. /**
  277. * Overwrite default settings.
  278. *
  279. * @param [ Object ] newDefaults New default values.
  280. *
  281. * @return [ Void ]
  282. */
  283. exports.setDefaults = function (defaults) {
  284. this.core.setDefaults(defaults);
  285. };
  286. /**
  287. * Register callback for given event.
  288. *
  289. * @param [ String ] event The name of the event.
  290. * @param [ Function ] callback The function to be exec as callback.
  291. * @param [ Object ] scope The callback function's scope.
  292. *
  293. * @return [ Void ]
  294. */
  295. exports.on = function (event, callback, scope) {
  296. this.core.on(event, callback, scope);
  297. };
  298. /**
  299. * Unregister callback for given event.
  300. *
  301. * @param [ String ] event The name of the event.
  302. * @param [ Function ] callback The function to be exec as callback.
  303. *
  304. * @return [ Void ]
  305. */
  306. exports.un = function (event, callback) {
  307. this.core.un(event, callback);
  308. };