local-notification.js 9.6 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. * 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 notifications by id.
  70. *
  71. * @param [ Array<Int> ] ids The IDs of the notifications.
  72. * @param [ Function ] callback The function to be exec as the callback.
  73. * @param [ Object ] scope The callback function's scope.
  74. *
  75. * @return [ Void ]
  76. */
  77. exports.clear = function (ids, callback, scope) {
  78. this.core.clear(ids, callback, scope);
  79. };
  80. /**
  81. * Clear all triggered notifications.
  82. *
  83. * @param [ Function ] callback The function to be exec as the callback.
  84. * @param [ Object ] scope The callback function's scope.
  85. *
  86. * @return [ Void ]
  87. */
  88. exports.clearAll = function (callback, scope) {
  89. this.core.clearAll(callback, scope);
  90. };
  91. /**
  92. * Cancel the specified notifications by id.
  93. *
  94. * @param [ Array<Int> ] ids The IDs of the notifications.
  95. * @param [ Function ] callback The function to be exec as the callback.
  96. * @param [ Object ] scope The callback function's scope.
  97. *
  98. * @return [ Void ]
  99. */
  100. exports.cancel = function (ids, callback, scope) {
  101. this.core.cancel(ids, callback, scope);
  102. };
  103. /**
  104. * Cancel all scheduled notifications.
  105. *
  106. * @param [ Function ] callback The function to be exec as the callback.
  107. * @param [ Object ] scope The callback function's scope.
  108. *
  109. * @return [ Void ]
  110. */
  111. exports.cancelAll = function (callback, scope) {
  112. this.core.cancelAll(callback, scope);
  113. };
  114. /**
  115. * Check if a notification is present.
  116. *
  117. * @param [ Int ] id The ID of the notification.
  118. * @param [ Function ] callback The function to be exec as the callback.
  119. * @param [ Object ] scope The callback function's scope.
  120. *
  121. * @return [ Void ]
  122. */
  123. exports.isPresent = function (id, callback, scope) {
  124. this.core.isPresent(id, callback, scope);
  125. };
  126. /**
  127. * Check if a notification is scheduled.
  128. *
  129. * @param [ Int ] id The ID of the notification.
  130. * @param [ Function ] callback The function to be exec as the callback.
  131. * @param [ Object ] scope The callback function's scope.
  132. *
  133. * @return [ Void ]
  134. */
  135. exports.isScheduled = function (id, callback, scope) {
  136. this.core.isScheduled(id, callback, scope);
  137. };
  138. /**
  139. * Check if a notification was triggered.
  140. *
  141. * @param [ Int ] id The ID of the notification.
  142. * @param [ Function ] callback The function to be exec as the callback.
  143. * @param [ Object ] scope The callback function's scope.
  144. *
  145. * @return [ Void ]
  146. */
  147. exports.isTriggered = function (id, callback, scope) {
  148. this.core.isTriggered(id, callback, scope);
  149. };
  150. /**
  151. * List of all notification ids.
  152. *
  153. * @param [ Function ] callback The function to be exec as the callback.
  154. * @param [ Object ] scope The callback function's scope.
  155. *
  156. * @return [ Void ]
  157. */
  158. exports.getAllIds = function (callback, scope) {
  159. this.core.getAllIds(callback, scope);
  160. };
  161. /**
  162. * Alias for `getAllIds`.
  163. */
  164. exports.getIds = function () {
  165. this.getAllIds.apply(this, arguments);
  166. };
  167. /**
  168. * List of all scheduled notification IDs.
  169. *
  170. * @param [ Function ] callback The function to be exec as the callback.
  171. * @param [ Object ] scope The callback function's scope.
  172. *
  173. * @return [ Void ]
  174. */
  175. exports.getScheduledIds = function (callback, scope) {
  176. this.core.getScheduledIds(callback, scope);
  177. };
  178. /**
  179. * List of all triggered notification IDs.
  180. *
  181. * @param [ Function ] callback The function to be exec as the callback.
  182. * @param [ Object ] scope The callback function's scope.
  183. *
  184. * @return [ Void ]
  185. */
  186. exports.getTriggeredIds = function (callback, scope) {
  187. this.core.getTriggeredIds(callback, scope);
  188. };
  189. /**
  190. * List of local notifications specified by id.
  191. * If called without IDs, all notification will be returned.
  192. *
  193. * @param [ Array<Int> ] ids The IDs of the notifications.
  194. * @param [ Function ] callback The function to be exec as the callback.
  195. * @param [ Object ] scope The callback function's scope.
  196. *
  197. * @return [ Void ]
  198. */
  199. exports.get = function (ids, callback, scope) {
  200. this.core.get(ids, callback, scope);
  201. };
  202. /**
  203. * List for all notifications.
  204. *
  205. * @param [ Function ] callback The function to be exec as the callback.
  206. * @param [ Object ] scope The callback function's scope.
  207. *
  208. * @return [ Void ]
  209. */
  210. exports.getAll = function (callback, scope) {
  211. this.core.getAll(callback, scope);
  212. };
  213. /**
  214. * List of scheduled notifications specified by id.
  215. * If called without IDs, all notification will be returned.
  216. *
  217. * @param [ Array<Int> ] ids The IDs of the notifications.
  218. * @param [ Function ] callback The function to be exec as the callback.
  219. * @param [ Object ] scope The callback function's scope.
  220. *
  221. * @return [ Void ]
  222. */
  223. exports.getScheduled = function (ids, callback, scope) {
  224. this.core.getScheduled(ids, callback, scope);
  225. };
  226. /**
  227. * List of all scheduled notifications.
  228. *
  229. * @param [ Function ] callback The function to be exec as the callback.
  230. * @param [ Object ] scope The callback function's scope.
  231. */
  232. exports.getAllScheduled = function (callback, scope) {
  233. this.core.getAllScheduled(callback, scope);
  234. };
  235. /**
  236. * List of triggered notifications specified by id.
  237. * If called without IDs, all notification will be returned.
  238. *
  239. * @param [ Array<Int> ] ids The IDs of the notifications.
  240. * @param [ Function ] callback The function to be exec as the callback.
  241. * @param [ Object ] scope The callback function's scope.
  242. *
  243. * @return [ Void ]
  244. */
  245. exports.getTriggered = function (ids, callback, scope) {
  246. this.core.getTriggered(ids, callback, scope);
  247. };
  248. /**
  249. * List of all triggered notifications.
  250. *
  251. * @param [ Function ] callback The function to be exec as the callback.
  252. * @param [ Object ] scope The callback function's scope.
  253. */
  254. exports.getAllTriggered = function (callback, scope) {
  255. this.core.getAllTriggered(callback, scope);
  256. };
  257. /**
  258. * Register an group of actions by id.
  259. *
  260. * @param [ String ] id The Id of the group.
  261. * @param [ Array] actions The action config settings.
  262. * @param [ Function ] callback The function to be exec as the callback.
  263. * @param [ Object ] scope The callback function's scope.
  264. *
  265. * @return [ Void ]
  266. */
  267. exports.addActionGroup = function (id, actions, callback, scope) {
  268. this.core.registerActionGroup(id, actions, callback, scope);
  269. };
  270. /**
  271. * The (platform specific) default settings.
  272. *
  273. * @return [ Object ]
  274. */
  275. exports.getDefaults = function () {
  276. return this.core.getDefaults();
  277. };
  278. /**
  279. * Overwrite default settings.
  280. *
  281. * @param [ Object ] newDefaults New default values.
  282. *
  283. * @return [ Void ]
  284. */
  285. exports.setDefaults = function (defaults) {
  286. this.core.setDefaults(defaults);
  287. };
  288. /**
  289. * Register callback for given event.
  290. *
  291. * @param [ String ] event The name of the event.
  292. * @param [ Function ] callback The function to be exec as callback.
  293. * @param [ Object ] scope The callback function's scope.
  294. *
  295. * @return [ Void ]
  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 The name of the event.
  304. * @param [ Function ] callback The function to be exec as callback.
  305. *
  306. * @return [ Void ]
  307. */
  308. exports.un = function (event, callback) {
  309. this.core.un(event, callback);
  310. };