UNPKG

18.3 kBTypeScriptView Raw
1import { IonicNativePlugin } from '@ionic-native/core';
2import { Observable } from 'rxjs';
3export declare enum ELocalNotificationTriggerUnit {
4 SECOND = "second",
5 MINUTE = "minute",
6 HOUR = "hour",
7 DAY = "day",
8 WEEK = "week",
9 MONTH = "month",
10 QUARTER = "quarter",
11 YEAR = "year",
12 WEEKDAY = "weekday",
13 WEEKDAY_ORDINAL = "weekdayOrdinal",
14 WEEK_OF_MONTH = "weekOfMonth"
15}
16export interface ILocalNotificationEvery {
17 /**
18 * The minute.
19 */
20 minute?: number;
21 /**
22 * The hour.
23 */
24 hour?: number;
25 /**
26 * The day.
27 */
28 day?: number;
29 /**
30 * The day of week.
31 */
32 weekday?: number;
33 /**
34 * The week of yeaday of the ardinal week.
35 */
36 week?: number;
37 /**
38 * The day of the ordinal week.
39 */
40 weekdayOrdinal?: number;
41 /**
42 * The week of month.
43 */
44 weekOfMonth?: number;
45 /**
46 * The month.
47 */
48 month?: number;
49 /**
50 * The quarter.
51 */
52 quarter?: number;
53 /**
54 * The year.
55 */
56 year?: number;
57}
58export interface ILocalNotificationTrigger {
59 /** ***** FIX ***** */
60 /**
61 * The date and time when the system should deliver the local notification. If the specified value is nil or is a date in the past, the local notification is delivered immediately.
62 * Default: now ~ new Date()
63 */
64 at?: Date;
65 /** ***** TIMESPAN ***** */
66 /**
67 * Amount of units
68 */
69 in?: number;
70 /**
71 * Unit
72 */
73 unit?: ELocalNotificationTriggerUnit;
74 /** ***** REPEAT/MATCH ***** */
75 /**
76 * Amount of units
77 */
78 count?: number;
79 /**
80 * The unit
81 */
82 every?: ELocalNotificationTriggerUnit | ILocalNotificationEvery;
83 /**
84 * The end of the repeating notification
85 */
86 before?: Date;
87 /**
88 * The date and time when the system should deliver the local notification. If the specified value is nil or is a date in the past, the local notification is delivered immediately.
89 * Only for "repeat"
90 * Default: now ~ new Date()
91 */
92 firstAt?: Date;
93 /**
94 * Only for "match"
95 */
96 after?: Date;
97 /** ***** LOCATION ***** */
98 /**
99 * IOS ONLY
100 * Center of the location
101 * Latitude and Longitude values
102 */
103 center?: number[];
104 /**
105 * IOS ONLY
106 * Radius in meters
107 */
108 radius?: number;
109 /**
110 * IOS ONLY
111 * Trigger on entry of the location
112 */
113 notifyOnEntry?: boolean;
114 /**
115 * IOS ONLY
116 * Trigger on exit of the location
117 */
118 notifyOnExit?: boolean;
119 /**
120 * IOS ONLY
121 * Trigger only once?
122 */
123 single?: boolean;
124}
125export declare enum ILocalNotificationActionType {
126 INPUT = "input",
127 BUTTON = "button"
128}
129/**
130 * Notification action
131 *
132 * @see https://github.com/katzer/cordova-plugin-local-notifications#actions
133 */
134export interface ILocalNotificationAction {
135 /**
136 * The id of the action is used as the event name in the listener function
137 */
138 id?: string;
139 /**
140 * The title of the notification message
141 */
142 title?: string;
143 /**
144 * Make this notification show when app in foreground.
145 */
146 foreground?: boolean;
147 /**
148 * Specifies whether the action causes the app to launch in the foreground
149 */
150 launch?: boolean;
151 /**
152 * If the value is 'decline' the action is displayed with special highlighting to indicate that it performs a destructive task
153 */
154 ui?: string;
155 /**
156 * Specifies whether the action requires that the user’s device be unlocked.
157 * When the user selects an action with this option, the system prompts
158 * the user to unlock the device
159 */
160 needsAuth?: boolean;
161 /**
162 * The resource path of the action icon
163 */
164 icon?: string;
165 /**
166 * ANDROID ONLY
167 * An array of pre-defined choices for users input
168 */
169 choices?: string[];
170 /**
171 * ANDROID ONLY
172 * Specifies whether the user can provide arbitrary text values
173 */
174 editable?: boolean;
175 /**
176 * IOS ONLY
177 * The title of the text input button that is displayed to the user.
178 */
179 submitTitle?: string;
180 /**
181 * The type of the action. If omitted 'button' is used.
182 */
183 type?: ILocalNotificationActionType;
184}
185export interface ILocalNotificationProgressBar {
186 /**
187 * Is the progress bar enabled?
188 */
189 enabled?: boolean;
190 /**
191 * The current value
192 */
193 value?: number;
194 /**
195 * ANDROID ONLY
196 * The maximum value (default is 100)
197 */
198 maxValue?: number;
199 /**
200 * ANDROID ONLY
201 * Show an indeterminate progress bar
202 */
203 indeterminate?: boolean;
204 /**
205 * WINDOWS ONLY
206 * Gets or sets an optional string to be displayed instead of the
207 * default percentage string. If this isn't provided, something
208 * like "70%" will be displayed.
209 */
210 description?: string;
211 /**
212 * WINDOWS ONLY
213 * Sets the status (required), which is displayed underneath the progress bar
214 * on the left.
215 * This string should reflect the status of the operation,
216 * like "Downloading..." or "Installing..."
217 */
218 status?: string;
219}
220export interface ILocalNotification {
221 /**
222 * A unique identifier required to clear, cancel, update or retrieve the local notification in the future
223 * Default: 0
224 */
225 id?: number;
226 /**
227 * First row of the notification
228 * Default: Empty string (iOS) or the app name (Android)
229 */
230 title?: string;
231 /**
232 * Second row of the notification
233 * Default: Empty string
234 */
235 text?: string | string[];
236 /**
237 * The number currently set as the badge of the app icon in Springboard (iOS) or at the right-hand side of the local notification (Android)
238 * Default: 0 (which means don't show a number)
239 */
240 badge?: number;
241 /**
242 * Uri of the file containing the sound to play when an alert is displayed
243 * Default: res://platform_default
244 */
245 sound?: string;
246 /**
247 * Arbitrary data, objects will be encoded to JSON string
248 * Default: null
249 */
250 data?: any;
251 /**
252 * ANDROID ONLY
253 * Uri of the icon that is shown in the ticker and notification
254 * Default: res://icon
255 */
256 icon?: string;
257 /**
258 * ANDROID ONLY
259 * Uri of the resource (only res://) to use in the notification layouts. Different classes of devices may return different sizes
260 * Default: res://ic_popup_reminder
261 */
262 smallIcon?: string;
263 /**
264 * ANDROID ONLY
265 * RGB value for the background color of the smallIcon.
266 * Default: Androids COLOR_DEFAULT, which will vary based on Android version.
267 */
268 color?: string;
269 /**
270 * ANDROID ONLY
271 * Use the default notification vibrate.
272 */
273 vibrate?: boolean;
274 /**
275 * ANDROID ONLY
276 * Define the blinking of the LED on the device.
277 * If set to true, the LED will blink in the default color with
278 * timings for on and off set to 1000 ms.
279 * If set to a string, the LED will blink in this ARGB value with
280 * timings for on and off set to 1000 ms.
281 * If set to an array, the value of the key 0 will be used as the color,
282 * the value of the key 1 will be used as the 'on' timing, the value of
283 * the key 2 will be used as the 'off' timing
284 */
285 led?: {
286 color: string;
287 on: number;
288 off: number;
289 } | any[] | boolean | string;
290 /**
291 * Notification priority.
292 * Integers between -2 and 2, whereas -2 is minimum and 2 is maximum priority
293 */
294 priority?: number;
295 /**
296 * Is a silent notification
297 */
298 silent?: boolean;
299 /**
300 * Specifies whether the a click on the notification causes the app
301 * to launch in the foreground
302 */
303 launch?: boolean;
304 /**
305 * ANDROID ONLY
306 * Wakeup the device. (default is true)
307 */
308 wakeup?: boolean;
309 /**
310 * ANDROID ONLY
311 * Specifies a duration in milliseconds after which this notification should be canceled, if it is not already canceled.
312 */
313 timeoutAfter?: number | false;
314 /**
315 * Actions id or actions
316 */
317 actions?: string | ILocalNotificationAction[];
318 /**
319 * When to trigger the notification
320 */
321 trigger?: ILocalNotificationTrigger;
322 /**
323 * A list of image attachments
324 */
325 attachments?: string[];
326 /**
327 * ANDROID ONLY
328 * If and how the notification shall show the when date.
329 * Possbile values:
330 * boolean: true equals 'clock', false disable a watch/counter
331 * 'clock': Show the when date in the content view
332 * 'chronometer': Show a stopwatch
333 *
334 */
335 clock?: boolean | string;
336 /**
337 * Shows a progress bar
338 * Setting a boolean is a shortcut for {enabled: true/false} respectively
339 */
340 progressBar?: ILocalNotificationProgressBar | boolean;
341 /**
342 * ANDROID ONLY
343 * If multiple notifications have the same group your app can present
344 * them as a single group.
345 */
346 group?: string;
347 /**
348 * ANDROID ONLY
349 * If set to 'true' this notification could use 'summary' to summarize
350 * the contents of the whole group
351 */
352 groupSummary?: boolean;
353 /**
354 * ANDROID ONLY
355 * Summary of the whole notification group. Should be used in conjuntion
356 * with 'groupSummary' set to true
357 */
358 summary?: string;
359 /**
360 * ANDROID ONLY
361 * Sets the number of items this notification represents.
362 */
363 number?: number;
364 /**
365 * ANDROID ONLY
366 * Set whether this is an "ongoing" notification.
367 * Ongoing notifications cannot be dismissed by the user,
368 * so your application or service must take care of canceling them.
369 */
370 sticky?: boolean;
371 /**
372 * ANDROID ONLY
373 * Make this notification automatically dismissed when the user touches it.
374 */
375 autoClear?: boolean;
376 /**
377 * ANDROID ONLY
378 * If set to true the notification will be show in its entirety on all lockscreens.
379 * If set to false it will not be revealed on a secure lockscreen.
380 */
381 lockscreen?: boolean;
382 /**
383 * ANDROID ONLY
384 * Set the default notification options that will be used.
385 * The value should be one or more of the following fields combined with
386 * bitwise-or: DEFAULT_SOUND, DEFAULT_VIBRATE, DEFAULT_LIGHTS.
387 */
388 defaults?: number;
389 /**
390 * ANDROID ONLY
391 * Specifies the channel the notification should be delivered on.
392 */
393 channel?: string;
394 /**
395 * ANDROID ONLY
396 * Set the token for the media session
397 */
398 mediaSession?: string;
399 /**
400 * Make this notification show when app in foreground.
401 */
402 foreground?: boolean;
403}
404/**
405 * @name Local Notifications
406 * @description
407 * This plugin allows you to display local notifications on the device
408 *
409 * @usage
410 * ```typescript
411 * import { LocalNotifications } from '@ionic-native/local-notifications/ngx';
412 *
413 *
414 * constructor(private localNotifications: LocalNotifications) { }
415 *
416 * ...
417 *
418 *
419 * // Schedule a single notification
420 * this.localNotifications.schedule({
421 * id: 1,
422 * text: 'Single ILocalNotification',
423 * sound: isAndroid? 'file://sound.mp3': 'file://beep.caf',
424 * data: { secret: key }
425 * });
426 *
427 *
428 * // Schedule multiple notifications
429 * this.localNotifications.schedule([{
430 * id: 1,
431 * text: 'Multi ILocalNotification 1',
432 * sound: isAndroid ? 'file://sound.mp3': 'file://beep.caf',
433 * data: { secret:key }
434 * },{
435 * id: 2,
436 * title: 'Local ILocalNotification Example',
437 * text: 'Multi ILocalNotification 2',
438 * icon: 'http://example.com/icon.png'
439 * }]);
440 *
441 *
442 * // Schedule delayed notification
443 * this.localNotifications.schedule({
444 * text: 'Delayed ILocalNotification',
445 * trigger: {at: new Date(new Date().getTime() + 3600)},
446 * led: 'FF0000',
447 * sound: null
448 * });
449 * ```
450 * @interfaces
451 * ILocalNotification
452 */
453export declare class LocalNotificationsOriginal extends IonicNativePlugin {
454 /**
455 * Informs if the app has the permission to show notifications.
456 * @returns {Promise<boolean>}
457 */
458 hasPermission(): Promise<boolean>;
459 /**
460 * Request permission to show notifications if not already granted.
461 * @returns {Promise<boolean>}
462 */
463 requestPermission(): Promise<boolean>;
464 /**
465 * Schedules a single or multiple notifications
466 * @param options {Notification | ILocalNotification[]} optional
467 */
468 schedule(options?: ILocalNotification | ILocalNotification[]): void;
469 /**
470 * Updates a previously scheduled notification. Must include the id in the options parameter.
471 * @param options {ILocalNotification} optional
472 */
473 update(options?: ILocalNotification): void;
474 /**
475 * Clears single or multiple notifications
476 * @param notificationId {any} A single notification id, or an array of notification ids.
477 * @returns {Promise<any>} Returns a promise when the notification had been cleared
478 */
479 clear(notificationId: any): Promise<any>;
480 /**
481 * Clears all notifications
482 * @returns {Promise<any>} Returns a promise when all notifications have cleared
483 */
484 clearAll(): Promise<any>;
485 /**
486 * Cancels single or multiple notifications
487 * @param notificationId {any} A single notification id, or an array of notification ids.
488 * @returns {Promise<any>} Returns a promise when the notification is canceled
489 */
490 cancel(notificationId: any): Promise<any>;
491 /**
492 * Cancels all notifications
493 * @returns {Promise<any>} Returns a promise when all notifications are canceled
494 */
495 cancelAll(): Promise<any>;
496 /**
497 * Checks presence of a notification
498 * @param notificationId {number}
499 * @returns {Promise<boolean>}
500 */
501 isPresent(notificationId: number): Promise<boolean>;
502 /**
503 * Checks is a notification is scheduled
504 * @param notificationId {number}
505 * @returns {Promise<boolean>}
506 */
507 isScheduled(notificationId: number): Promise<boolean>;
508 /**
509 * Checks if a notification is triggered
510 * @param notificationId {number}
511 * @returns {Promise<boolean>}
512 */
513 isTriggered(notificationId: number): Promise<boolean>;
514 /**
515 * Check if a notification has a given type.
516 * @param {number} id The ID of the notification.
517 * @param {string} type The type of the notification.
518 * @returns {Promise<boolean>}
519 */
520 hasType(id: number, type: string): Promise<boolean>;
521 /**
522 * Get the type (triggered, scheduled) for the notification.
523 * @param {number} id The ID of the notification.
524 */
525 getType(id: number): Promise<boolean>;
526 /**
527 * Get all the notification ids
528 * @returns {Promise<Array<number>>}
529 */
530 getIds(): Promise<number[]>;
531 /**
532 * Get the ids of scheduled notifications
533 * @returns {Promise<number[]>} Returns a promise
534 */
535 getScheduledIds(): Promise<number[]>;
536 /**
537 * Get the ids of triggered notifications
538 * @returns {Promise<Array<number>>}
539 */
540 getTriggeredIds(): Promise<number[]>;
541 /**
542 * Get a notification object
543 * @param notificationId {any} The id of the notification to get
544 * @returns {Promise<ILocalNotification>}
545 */
546 get(notificationId: any): Promise<ILocalNotification>;
547 /**
548 * Get all notification objects
549 * @returns {Promise<ILocalNotification[]>}
550 */
551 getAll(): Promise<ILocalNotification[]>;
552 /**
553 * Get a scheduled notification object
554 * @param notificationId {any} The id of the notification to get
555 * @returns {Promise<ILocalNotification>}
556 */
557 getScheduled(notificationId: any): Promise<ILocalNotification>;
558 /**
559 * Get a triggered notification object
560 * @param notificationId The id of the notification to get
561 * @returns {Promise<ILocalNotification>}
562 */
563 getTriggered(notificationId: any): Promise<ILocalNotification>;
564 /**
565 * Adds a group of actions
566 * @param groupId The id of the action group
567 * @param actions The actions of this group
568 * @returns {Promise<any>}
569 */
570 addActions(groupId: any, actions: ILocalNotificationAction[]): Promise<any>;
571 /**
572 * Removes a group of actions
573 * @param groupId The id of the action group
574 * @returns {Promise<any>}
575 */
576 removeActions(groupId: any): Promise<any>;
577 /**
578 * Checks if a group of actions is defined
579 * @param groupId The id of the action group
580 * @returns {Promise<boolean>} Whether the group is defined
581 */
582 hasActions(groupId: any): Promise<boolean>;
583 /**
584 * Gets the (platform specific) default settings.
585 * @returns {Promise<any>} An object with all default settings
586 */
587 getDefaults(): Promise<any>;
588 /**
589 * Overwrites the (platform specific) default settings.
590 * @returns {Promise<any>}
591 */
592 setDefaults(defaults: any): Promise<any>;
593 /**
594 * Get all scheduled notification objects
595 * @returns {Promise<Array<ILocalNotification>>}
596 */
597 getAllScheduled(): Promise<ILocalNotification[]>;
598 /**
599 * Get all triggered notification objects
600 * @returns {Promise<Array<ILocalNotification>>}
601 */
602 getAllTriggered(): Promise<ILocalNotification[]>;
603 /**
604 * Sets a callback for a specific event
605 * @param eventName {string} The name of the event. Available events: schedule, trigger, click, update, clear, clearall, cancel, cancelall. Custom event names are possible for actions
606 * @return {Observable}
607 */
608 on(eventName: string): Observable<any>;
609 /**
610 * Not an official interface, however its possible to manually fire events.
611 * @param eventName The name of the event. Available events: schedule, trigger, click, update, clear, clearall, cancel, cancelall. Custom event names are possible for actions
612 * @param args Optional arguments
613 */
614 fireEvent(eventName: string, args: any): void;
615 /**
616 * Fire queued events once the device is ready and all listeners are registered.
617 * @returns {Promise<any>}
618 */
619 fireQueuedEvents(): Promise<any>;
620}
621
622export declare const LocalNotifications: LocalNotificationsOriginal;
\No newline at end of file