UNPKG

9.29 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var plugin_1 = require('./plugin');
9/**
10 * @name Local Notifications
11 * @description
12 * This plugin allows you to display local notifications on the device
13 *
14 * @usage
15 * ```typescript
16 * import { LocalNotifications } from 'ionic-native';
17 *
18 *
19 * // Schedule a single notification
20 * LocalNotifications.schedule({
21 * id: 1,
22 * text: 'Single ILocalNotification',
23 * sound: isAndroid? 'file://sound.mp3': 'file://beep.caf',
24 * data: { secret: key }
25 * });
26 *
27 *
28 * // Schedule multiple notifications
29 * LocalNotifications.schedule([{
30 * id: 1,
31 * text: 'Multi ILocalNotification 1',
32 * sound: isAndroid ? 'file://sound.mp3': 'file://beep.caf',
33 * data: { secret:key }
34 * },{
35 * id: 2,
36 * title: 'Local ILocalNotification Example',
37 * text: 'Multi ILocalNotification 2',
38 * icon: 'http://example.com/icon.png'
39 * }]);
40 *
41 *
42 * // Schedule delayed notification
43 * LocalNotifications.schedule({
44 * text: 'Delayed ILocalNotification',
45 * at: new Date(new Date().getTime() + 3600),
46 * led: 'FF0000',
47 * sound: null
48 * });
49 * ```
50 * @interfaces
51 * ILocalNotification
52 */
53var LocalNotifications = (function () {
54 function LocalNotifications() {
55 }
56 /**
57 * Schedules a single or multiple notifications
58 * @param options {Notification | Array<ILocalNotification>} optional
59 */
60 LocalNotifications.schedule = function (options) { };
61 /**
62 * Updates a previously scheduled notification. Must include the id in the options parameter.
63 * @param options {ILocalNotification} optional
64 */
65 LocalNotifications.update = function (options) { };
66 /**
67 * Clears single or multiple notifications
68 * @param notificationId {any} A single notification id, or an array of notification ids.
69 * @returns {Promise<any>} Returns a promise when the notification had been cleared
70 */
71 LocalNotifications.clear = function (notificationId) { return; };
72 /**
73 * Clears all notifications
74 * @returns {Promise<any>} Returns a promise when all notifications have cleared
75 */
76 LocalNotifications.clearAll = function () { return; };
77 /**
78 * Cancels single or multiple notifications
79 * @param notificationId {any} A single notification id, or an array of notification ids.
80 * @returns {Promise<any>} Returns a promise when the notification is canceled
81 */
82 LocalNotifications.cancel = function (notificationId) { return; };
83 /**
84 * Cancels all notifications
85 * @returns {Promise<any>} Returns a promise when all notifications are canceled
86 */
87 LocalNotifications.cancelAll = function () { return; };
88 /**
89 * Checks presence of a notification
90 * @param notificationId {number}
91 * @returns {Promise<boolean>}
92 */
93 LocalNotifications.isPresent = function (notificationId) { return; };
94 /**
95 * Checks is a notification is scheduled
96 * @param notificationId {number}
97 * @returns {Promise<boolean>}
98 */
99 LocalNotifications.isScheduled = function (notificationId) { return; };
100 /**
101 * Checks if a notification is triggered
102 * @param notificationId {number}
103 * @returns {Promise<boolean>}
104 */
105 LocalNotifications.isTriggered = function (notificationId) { return; };
106 /**
107 * Get all the notification ids
108 * @returns {Promise<Array<number>>}
109 */
110 LocalNotifications.getAllIds = function () { return; };
111 /**
112 * Get the ids of triggered notifications
113 * @returns {Promise<Array<number>>}
114 */
115 LocalNotifications.getTriggeredIds = function () { return; };
116 /**
117 * Get the ids of scheduled notifications
118 * @returns {Promise<Array<number>>} Returns a promise
119 */
120 LocalNotifications.getScheduledIds = function () { return; };
121 /**
122 * Get a notification object
123 * @param notificationId {any} The id of the notification to get
124 * @returns {Promise<ILocalNotification>}
125 */
126 LocalNotifications.get = function (notificationId) { return; };
127 /**
128 * Get a scheduled notification object
129 * @param notificationId {any} The id of the notification to get
130 * @returns {Promise<ILocalNotification>}
131 */
132 LocalNotifications.getScheduled = function (notificationId) { return; };
133 /**
134 * Get a triggered notification object
135 * @param notificationId The id of the notification to get
136 * @returns {Promise<ILocalNotification>}
137 */
138 LocalNotifications.getTriggered = function (notificationId) { return; };
139 /**
140 * Get all notification objects
141 * @returns {Promise<Array<ILocalNotification>>}
142 */
143 LocalNotifications.getAll = function () { return; };
144 /**
145 * Get all scheduled notification objects
146 * @returns {Promise<Array<ILocalNotification>>}
147 */
148 LocalNotifications.getAllScheduled = function () { return; };
149 /**
150 * Get all triggered notification objects
151 * @returns {Promise<Array<ILocalNotification>>}
152 */
153 LocalNotifications.getAllTriggered = function () { return; };
154 /**
155 * Register permission to show notifications if not already granted.
156 * @returns {Promise<boolean>}
157 */
158 LocalNotifications.registerPermission = function () { return; };
159 /**
160 * Informs if the app has the permission to show notifications.
161 * @returns {Promise<boolean>}
162 */
163 LocalNotifications.hasPermission = function () { return; };
164 /**
165 * Sets a callback for a specific event
166 * @param eventName The name of the event. Available events: schedule, trigger, click, update, clear, clearall, cancel, cancelall
167 * @param callback Call back function. All events return notification and state parameter. clear and clearall return state parameter only.
168 */
169 LocalNotifications.on = function (eventName, callback) { };
170 __decorate([
171 plugin_1.Cordova({
172 sync: true
173 })
174 ], LocalNotifications, "schedule", null);
175 __decorate([
176 plugin_1.Cordova({
177 sync: true
178 })
179 ], LocalNotifications, "update", null);
180 __decorate([
181 plugin_1.Cordova()
182 ], LocalNotifications, "clear", null);
183 __decorate([
184 plugin_1.Cordova({
185 successIndex: 0,
186 errorIndex: 2
187 })
188 ], LocalNotifications, "clearAll", null);
189 __decorate([
190 plugin_1.Cordova()
191 ], LocalNotifications, "cancel", null);
192 __decorate([
193 plugin_1.Cordova({
194 successIndex: 0,
195 errorIndex: 2
196 })
197 ], LocalNotifications, "cancelAll", null);
198 __decorate([
199 plugin_1.Cordova()
200 ], LocalNotifications, "isPresent", null);
201 __decorate([
202 plugin_1.Cordova()
203 ], LocalNotifications, "isScheduled", null);
204 __decorate([
205 plugin_1.Cordova()
206 ], LocalNotifications, "isTriggered", null);
207 __decorate([
208 plugin_1.Cordova()
209 ], LocalNotifications, "getAllIds", null);
210 __decorate([
211 plugin_1.Cordova()
212 ], LocalNotifications, "getTriggeredIds", null);
213 __decorate([
214 plugin_1.Cordova()
215 ], LocalNotifications, "getScheduledIds", null);
216 __decorate([
217 plugin_1.Cordova()
218 ], LocalNotifications, "get", null);
219 __decorate([
220 plugin_1.Cordova()
221 ], LocalNotifications, "getScheduled", null);
222 __decorate([
223 plugin_1.Cordova()
224 ], LocalNotifications, "getTriggered", null);
225 __decorate([
226 plugin_1.Cordova()
227 ], LocalNotifications, "getAll", null);
228 __decorate([
229 plugin_1.Cordova()
230 ], LocalNotifications, "getAllScheduled", null);
231 __decorate([
232 plugin_1.Cordova()
233 ], LocalNotifications, "getAllTriggered", null);
234 __decorate([
235 plugin_1.Cordova()
236 ], LocalNotifications, "registerPermission", null);
237 __decorate([
238 plugin_1.Cordova()
239 ], LocalNotifications, "hasPermission", null);
240 __decorate([
241 plugin_1.Cordova({
242 sync: true
243 })
244 ], LocalNotifications, "on", null);
245 LocalNotifications = __decorate([
246 plugin_1.Plugin({
247 pluginName: 'LocalNotifications',
248 plugin: 'de.appplant.cordova.plugin.local-notification',
249 pluginRef: 'cordova.plugins.notification.local',
250 repo: 'https://github.com/katzer/cordova-plugin-local-notifications'
251 })
252 ], LocalNotifications);
253 return LocalNotifications;
254}());
255exports.LocalNotifications = LocalNotifications;
256//# sourceMappingURL=localnotifications.js.map
\No newline at end of file