@@ -35,23 +35,39 @@ export class LocalNotificationsImpl extends LocalNotificationsCommon implements
35
35
36
36
switch ( interval ) {
37
37
default :
38
- case 'second' : multiplier = 1000 ; break ;
39
- case 'minute' : multiplier = android . app . AlarmManager . INTERVAL_HOUR / 60 ; break ;
40
- case 'hour' : multiplier = android . app . AlarmManager . INTERVAL_HOUR ; break ;
41
- case 'day' : multiplier = android . app . AlarmManager . INTERVAL_DAY ; break ;
42
- case 'week' : multiplier = android . app . AlarmManager . INTERVAL_DAY * 7 ; break ;
38
+ case 'second' :
39
+ multiplier = 1000 ;
40
+ break ;
41
+ case 'minute' :
42
+ multiplier = android . app . AlarmManager . INTERVAL_HOUR / 60 ;
43
+ break ;
44
+ case 'hour' :
45
+ multiplier = android . app . AlarmManager . INTERVAL_HOUR ;
46
+ break ;
47
+ case 'day' :
48
+ multiplier = android . app . AlarmManager . INTERVAL_DAY ;
49
+ break ;
50
+ case 'week' :
51
+ multiplier = android . app . AlarmManager . INTERVAL_DAY * 7 ;
52
+ break ;
43
53
// close enough
44
- case 'month' : multiplier = android . app . AlarmManager . INTERVAL_DAY * 31 ; break ;
45
- case 'quarter' : multiplier = android . app . AlarmManager . INTERVAL_DAY * 31 * 3 ; break ;
46
- case 'year' : multiplier = android . app . AlarmManager . INTERVAL_DAY * 365 ; break ;
54
+ case 'month' :
55
+ multiplier = android . app . AlarmManager . INTERVAL_DAY * 31 ;
56
+ break ;
57
+ case 'quarter' :
58
+ multiplier = android . app . AlarmManager . INTERVAL_DAY * 31 * 3 ;
59
+ break ;
60
+ case 'year' :
61
+ multiplier = android . app . AlarmManager . INTERVAL_DAY * 365 ;
62
+ break ;
47
63
}
48
64
49
65
return Math . abs ( ticks ) * multiplier ;
50
66
}
51
67
52
68
private static getIcon ( context : any /* android.content.Context */ , resources : any , iconLocation ?: string ) : string {
53
69
const packageName : string = context . getApplicationInfo ( ) . packageName ;
54
- return ( iconLocation && iconLocation . indexOf ( Utils . RESOURCE_PREFIX ) === 0 && resources . getIdentifier ( iconLocation . substr ( Utils . RESOURCE_PREFIX . length ) , 'drawable' , packageName ) ) || ( LocalNotificationsImpl . IS_GTE_LOLLIPOP && resources . getIdentifier ( 'ic_stat_notify_silhouette' , 'drawable' , packageName ) ) || resources . getIdentifier ( 'ic_stat_notify' , 'drawable' , packageName ) || context . getApplicationInfo ( ) . icon ;
70
+ return ( iconLocation && typeof iconLocation === 'string' && iconLocation . indexOf ( Utils . RESOURCE_PREFIX ) === 0 && resources . getIdentifier ( iconLocation . substr ( Utils . RESOURCE_PREFIX . length ) , 'drawable' , packageName ) ) || ( LocalNotificationsImpl . IS_GTE_LOLLIPOP && resources . getIdentifier ( 'ic_stat_notify_silhouette' , 'drawable' , packageName ) ) || resources . getIdentifier ( 'ic_stat_notify' , 'drawable' , packageName ) || context . getApplicationInfo ( ) . icon ;
55
71
}
56
72
57
73
private static cancelById ( id : number ) : void {
@@ -198,10 +214,8 @@ export class LocalNotificationsImpl extends LocalNotificationsCommon implements
198
214
for ( let n in scheduleOptions ) {
199
215
const triggers : Array < Record < string , any > > = [ ] ;
200
216
const options = LocalNotificationsImpl . merge ( scheduleOptions [ n ] , LocalNotificationsImpl . defaults ) ;
201
- const [ interval , ticks ] = ( ! ! options . interval ) && ( options . interval . constructor === Object )
202
- ? Object . entries ( options . interval || { } ) . shift ( ) as [ ScheduleInterval , number ] || [ ]
203
- : [ options . interval ] as [ ScheduleInterval ]
204
-
217
+ const [ interval , ticks ] = ! ! options . interval && options . interval . constructor === Object ? ( Object . entries ( options . interval || { } ) . shift ( ) as [ ScheduleInterval , number ] ) || [ ] : ( [ options . interval ] as [ ScheduleInterval ] ) ;
218
+
205
219
LocalNotificationsImpl . ensureID ( options ) ;
206
220
207
221
options . atTime = options . at ? options . at . getTime ( ) : - 1 ;
@@ -230,15 +244,15 @@ export class LocalNotificationsImpl extends LocalNotificationsCommon implements
230
244
triggers . push ( optionsClone ) ;
231
245
}
232
246
233
- triggers . forEach ( trigger => registerNotification ( trigger , context , scheduledIds ) ) ;
247
+ triggers . forEach ( ( trigger ) => registerNotification ( trigger , context , scheduledIds ) ) ;
234
248
}
235
249
236
250
return scheduledIds ;
237
251
} catch ( ex ) {
238
252
console . log ( 'Error in LocalNotifications.schedule: ' + ex ) ;
239
253
throw ex ;
240
254
}
241
-
255
+
242
256
function registerNotification ( options : Record < string , any > , context : globalAndroid . content . Context , register : Array < number > ) {
243
257
com . telerik . localnotifications . LocalNotificationsPlugin . scheduleNotification ( new org . json . JSONObject ( JSON . stringify ( options ) ) , context ) ;
244
258
register . push ( options . id ) ;
0 commit comments