Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
cordova-plugin-local-notifications
Commits
8418c152
Commit
8418c152
authored
Jan 08, 2015
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New interface methods `getScheduled` and `getTriggered` (iOS)
parent
40599e17
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
324 additions
and
163 deletions
+324
-163
APPLocalNotification.h
src/ios/APPLocalNotification.h
+6
-2
APPLocalNotification.m
src/ios/APPLocalNotification.m
+79
-21
UIApplication+APPLocalNotification.h
src/ios/UIApplication+APPLocalNotification.h
+8
-0
UIApplication+APPLocalNotification.m
src/ios/UIApplication+APPLocalNotification.m
+98
-14
local-notification.js
www/local-notification.js
+133
-126
No files found.
src/ios/APPLocalNotification.h
View file @
8418c152
...
@@ -36,10 +36,14 @@
...
@@ -36,10 +36,14 @@
-
(
void
)
isScheduled
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
isScheduled
:(
CDVInvokedUrlCommand
*
)
command
;
// Check if a notification with an ID was triggered
// Check if a notification with an ID was triggered
-
(
void
)
isTriggered
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
isTriggered
:(
CDVInvokedUrlCommand
*
)
command
;
//
Retrieve a list of
ids from all pending notifications
//
List all
ids from all pending notifications
-
(
void
)
getScheduledIds
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
getScheduledIds
:(
CDVInvokedUrlCommand
*
)
command
;
//
Retrieve a list of
ids from all triggered notifications
//
List all
ids from all triggered notifications
-
(
void
)
getTriggeredIds
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
getTriggeredIds
:(
CDVInvokedUrlCommand
*
)
command
;
// List all properties for given scheduled notifications
-
(
void
)
getScheduled
:(
CDVInvokedUrlCommand
*
)
command
;
// List all properties for given triggered notifications
-
(
void
)
getTriggered
:(
CDVInvokedUrlCommand
*
)
command
;
// Inform if the app has the permission to show notifications
// Inform if the app has the permission to show notifications
-
(
void
)
hasPermission
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
hasPermission
:(
CDVInvokedUrlCommand
*
)
command
;
// Register permission to show notifications
// Register permission to show notifications
...
...
src/ios/APPLocalNotification.m
View file @
8418c152
...
@@ -117,7 +117,7 @@
...
@@ -117,7 +117,7 @@
}
}
/**
/**
* Cancel
s
all currently scheduled notifications.
* Cancel all currently scheduled notifications.
*/
*/
-
(
void
)
cancelAll
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
cancelAll
:(
CDVInvokedUrlCommand
*
)
command
{
{
...
@@ -157,7 +157,35 @@
...
@@ -157,7 +157,35 @@
}
}
/**
/**
* List of ids from all currently pending notifications.
* Check if a notification with an ID was triggered.
*
* @param id
* The ID of the notification
*/
-
(
void
)
isTriggered
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSString
*
id
=
[[
command
arguments
]
objectAtIndex
:
0
];
CDVPluginResult
*
result
;
UILocalNotification
*
notification
;
notification
=
[[
UIApplication
sharedApplication
]
triggeredLocalNotificationWithId
:
id
];
bool
isTriggered
=
notification
!=
NULL
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsBool
:
isTriggered
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
}
/**
* List all ids from all pending notifications.
*/
*/
-
(
void
)
getScheduledIds
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
getScheduledIds
:(
CDVInvokedUrlCommand
*
)
command
{
{
...
@@ -177,27 +205,48 @@
...
@@ -177,27 +205,48 @@
}
}
/**
/**
* Checks wether a notification with an ID was triggered.
* List all ids from all triggered notifications.
*
* @param id
* The ID of the notification
*/
*/
-
(
void
)
isTriggered
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
getTriggeredIds
:(
CDVInvokedUrlCommand
*
)
command
{
{
[
self
.
commandDelegate
runInBackground
:
^
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSString
*
id
=
[[
command
arguments
]
objectAtIndex
:
0
];
CDVPluginResult
*
result
;
CDVPluginResult
*
result
;
UILocalNotification
*
notification
;
NSArray
*
triggeredIds
;
notification
=
[[
UIApplication
sharedApplication
]
triggeredIds
=
[[
UIApplication
sharedApplication
]
triggeredLocalNotification
WithId
:
id
];
triggeredLocalNotification
Ids
];
bool
isTriggered
=
notification
!=
NULL
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsArray
:
triggeredIds
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
}
/**
* List all properties for given scheduled notifications.
*
* @param ids
* The IDs of the notifications
*/
-
(
void
)
getScheduled
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSArray
*
ids
=
command
.
arguments
;
NSArray
*
notifications
;
CDVPluginResult
*
result
;
if
(
ids
.
count
==
0
)
{
notifications
=
[[
UIApplication
sharedApplication
]
scheduledLocalNotificationOptions
];
}
else
{
notifications
=
[[
UIApplication
sharedApplication
]
scheduledLocalNotificationOptions
:
ids
];
}
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsBool
:
isTriggered
];
messageAsArray
:
notifications
];
[
self
.
commandDelegate
sendPluginResult
:
result
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
callbackId
:
command
.
callbackId
];
...
@@ -205,19 +254,28 @@
...
@@ -205,19 +254,28 @@
}
}
/**
/**
* Retrieves a list of ids from all currently triggered notifications.
* List all properties for given triggered notifications.
*
* @param ids
* The IDs of the notifications
*/
*/
-
(
void
)
getTriggered
Ids
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
getTriggered
:(
CDVInvokedUrlCommand
*
)
command
{
{
[
self
.
commandDelegate
runInBackground
:
^
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSArray
*
ids
=
command
.
arguments
;
NSArray
*
notifications
;
CDVPluginResult
*
result
;
CDVPluginResult
*
result
;
NSArray
*
triggeredIds
;
triggeredIds
=
[[
UIApplication
sharedApplication
]
if
(
ids
.
count
==
0
)
{
triggeredLocalNotificationIds
];
notifications
=
[[
UIApplication
sharedApplication
]
triggeredLocalNotificationOptions
];
}
else
{
notifications
=
[[
UIApplication
sharedApplication
]
triggeredLocalNotificationOptions
:
ids
];
}
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsArray
:
triggeredId
s
];
messageAsArray
:
notification
s
];
[
self
.
commandDelegate
sendPluginResult
:
result
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
callbackId
:
command
.
callbackId
];
...
...
src/ios/UIApplication+APPLocalNotification.h
View file @
8418c152
...
@@ -33,5 +33,13 @@
...
@@ -33,5 +33,13 @@
-
(
UILocalNotification
*
)
scheduledLocalNotificationWithId
:(
NSString
*
)
id
;
-
(
UILocalNotification
*
)
scheduledLocalNotificationWithId
:(
NSString
*
)
id
;
// Get the triggered local notification by ID
// Get the triggered local notification by ID
-
(
UILocalNotification
*
)
triggeredLocalNotificationWithId
:(
NSString
*
)
id
;
-
(
UILocalNotification
*
)
triggeredLocalNotificationWithId
:(
NSString
*
)
id
;
// List of properties from all scheduled notifications
-
(
NSArray
*
)
scheduledLocalNotificationOptions
;
// List of properties from given scheduled notifications
-
(
NSArray
*
)
scheduledLocalNotificationOptions
:(
NSArray
*
)
ids
;
// List of properties from all triggered notifications
-
(
NSArray
*
)
triggeredLocalNotificationOptions
;
// List of properties from given triggered notifications
-
(
NSArray
*
)
triggeredLocalNotificationOptions
:(
NSArray
*
)
ids
;
@end
@end
src/ios/UIApplication+APPLocalNotification.m
View file @
8418c152
...
@@ -97,15 +97,15 @@
...
@@ -97,15 +97,15 @@
*/
*/
-
(
NSArray
*
)
triggeredLocalNotificationIds
-
(
NSArray
*
)
triggeredLocalNotificationIds
{
{
NSArray
*
triggeredN
otifications
=
self
.
triggeredLocalNotifications
;
NSArray
*
n
otifications
=
self
.
triggeredLocalNotifications
;
NSMutableArray
*
triggeredNotificationI
ds
=
[[
NSMutableArray
alloc
]
init
];
NSMutableArray
*
i
ds
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
triggeredN
otifications
)
for
(
UILocalNotification
*
notification
in
n
otifications
)
{
{
[
triggeredNotificationI
ds
addObject
:
notification
.
options
.
id
];
[
i
ds
addObject
:
notification
.
options
.
id
];
}
}
return
triggeredNotificationI
ds
;
return
i
ds
;
}
}
/**
/**
...
@@ -113,22 +113,24 @@
...
@@ -113,22 +113,24 @@
*/
*/
-
(
NSArray
*
)
scheduledLocalNotificationIds
-
(
NSArray
*
)
scheduledLocalNotificationIds
{
{
NSArray
*
scheduledN
otifications
=
self
.
scheduledLocalNotifications
;
NSArray
*
n
otifications
=
self
.
scheduledLocalNotifications
;
NSMutableArray
*
scheduledNotificationI
ds
=
[[
NSMutableArray
alloc
]
init
];
NSMutableArray
*
i
ds
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
scheduledN
otifications
)
for
(
UILocalNotification
*
notification
in
n
otifications
)
{
{
if
(
notification
)
if
(
notification
)
{
{
[
ids
addObject
:
notification
.
options
.
id
];
[
scheduledNotificationIds
addObject
:
notification
.
options
.
id
];
}
}
}
}
return
scheduledNotificationI
ds
;
return
i
ds
;
}
}
/**
/**
* Get the scheduled local notification by ID.
* Get the scheduled local notification by ID.
*
* @param id
* Notification ID
*/
*/
-
(
UILocalNotification
*
)
scheduledLocalNotificationWithId
:
(
NSString
*
)
id
-
(
UILocalNotification
*
)
scheduledLocalNotificationWithId
:
(
NSString
*
)
id
{
{
...
@@ -136,8 +138,7 @@
...
@@ -136,8 +138,7 @@
for
(
UILocalNotification
*
notification
in
notifications
)
for
(
UILocalNotification
*
notification
in
notifications
)
{
{
if
(
notification
&&
[
notification
.
options
.
id
isEqualToString
:
id
])
if
(
notification
&&
[
notification
.
options
.
id
isEqualToString
:
id
])
{
{
return
notification
;
return
notification
;
}
}
}
}
...
@@ -147,6 +148,9 @@
...
@@ -147,6 +148,9 @@
/**
/**
* Get the triggered local notification by ID.
* Get the triggered local notification by ID.
*
* @param id
* Notification ID
*/
*/
-
(
UILocalNotification
*
)
triggeredLocalNotificationWithId
:
(
NSString
*
)
id
-
(
UILocalNotification
*
)
triggeredLocalNotificationWithId
:
(
NSString
*
)
id
{
{
...
@@ -159,4 +163,84 @@
...
@@ -159,4 +163,84 @@
return
NULL
;
return
NULL
;
}
}
/**
* List of properties from all scheduled notifications.
*/
-
(
NSArray
*
)
scheduledLocalNotificationOptions
{
NSArray
*
notifications
=
self
.
scheduledLocalNotifications
;
NSMutableArray
*
options
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
notifications
)
{
if
(
notification
)
{
[
options
addObject
:
notification
.
userInfo
];
}
}
return
options
;
}
/**
* List of properties from given scheduled notifications.
*
* @param ids
* Notification IDs
*/
-
(
NSArray
*
)
scheduledLocalNotificationOptions
:
(
NSArray
*
)
ids
{
UILocalNotification
*
notification
;
NSMutableArray
*
options
=
[[
NSMutableArray
alloc
]
init
];
for
(
NSString
*
id
in
ids
)
{
notification
=
[
self
scheduledLocalNotificationWithId
:
id
];
if
(
notification
)
{
[
options
addObject
:
notification
.
userInfo
];
}
}
return
options
;
}
/**
* List of properties from all triggered notifications.
*/
-
(
NSArray
*
)
triggeredLocalNotificationOptions
{
NSArray
*
notifications
=
self
.
triggeredLocalNotifications
;
NSMutableArray
*
options
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
notifications
)
{
[
options
addObject
:
notification
.
userInfo
];
}
return
options
;
}
/**
* List of properties from given triggered notifications.
*
* @param ids
* Notification IDs
*/
-
(
NSArray
*
)
triggeredLocalNotificationOptions
:
(
NSArray
*
)
ids
{
UILocalNotification
*
notification
;
NSMutableArray
*
options
=
[[
NSMutableArray
alloc
]
init
];
for
(
NSString
*
id
in
ids
)
{
notification
=
[
self
triggeredLocalNotificationWithId
:
id
];
if
(
notification
)
{
[
options
addObject
:
notification
.
userInfo
];
}
}
return
options
;
}
@end
@end
www/local-notification.js
View file @
8418c152
...
@@ -102,7 +102,7 @@ exports.setDefaults = function (newDefaults) {
...
@@ -102,7 +102,7 @@ exports.setDefaults = function (newDefaults) {
* The notification properties
* The notification properties
* @param {Function} callback
* @param {Function} callback
* A function to be called after the notification has been canceled
* A function to be called after the notification has been canceled
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
add
=
function
(
props
,
callback
,
scope
)
{
exports
.
add
=
function
(
props
,
callback
,
scope
)
{
...
@@ -135,7 +135,7 @@ exports.add = function (props, callback, scope) {
...
@@ -135,7 +135,7 @@ exports.add = function (props, callback, scope) {
* The notification properties to update
* The notification properties to update
* @param {Function} callback
* @param {Function} callback
* A function to be called after the notification has been updated
* A function to be called after the notification has been updated
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
update
=
function
(
options
,
callback
,
scope
)
{
exports
.
update
=
function
(
options
,
callback
,
scope
)
{
...
@@ -143,13 +143,13 @@ exports.update = function (options, callback, scope) {
...
@@ -143,13 +143,13 @@ exports.update = function (options, callback, scope) {
};
};
/**
/**
* Clear
s
the specified notification.
* Clear the specified notification.
*
*
* @param {String} id
* @param {String} id
* The ID of the notification
* The ID of the notification
* @param {Function} callback
* @param {Function} callback
* A function to be called after the notification has been cleared
* A function to be called after the notification has been cleared
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
clear
=
function
(
id
,
callback
,
scope
)
{
exports
.
clear
=
function
(
id
,
callback
,
scope
)
{
...
@@ -159,11 +159,11 @@ exports.clear = function (id, callback, scope) {
...
@@ -159,11 +159,11 @@ exports.clear = function (id, callback, scope) {
};
};
/**
/**
* Clear
s
all previously sheduled notifications.
* Clear all previously sheduled notifications.
*
*
* @param {Function} callback
* @param {Function} callback
* A function to be called after all notifications have been cleared
* A function to be called after all notifications have been cleared
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
clearAll
=
function
(
callback
,
scope
)
{
exports
.
clearAll
=
function
(
callback
,
scope
)
{
...
@@ -171,22 +171,20 @@ exports.clearAll = function (callback, scope) {
...
@@ -171,22 +171,20 @@ exports.clearAll = function (callback, scope) {
};
};
/**
/**
* Cancel
s
the specified notifications.
* Cancel the specified notifications.
*
*
* @param {String[]} ids
* @param {String[]} ids
* The IDs of the notifications
* The IDs of the notifications
* @param {Function} callback
* @param {Function} callback
* A function to be called after the notifications has been canceled
* A function to be called after the notifications has been canceled
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
cancel
=
function
(
ids
,
callback
,
scope
)
{
exports
.
cancel
=
function
(
ids
,
callback
,
scope
)
{
ids
=
Array
.
isArray
(
ids
)
?
ids
:
[
ids
];
ids
=
Array
.
isArray
(
ids
)
?
ids
:
[
ids
];
for
(
var
i
=
0
;
i
<
ids
.
length
;
i
++
)
{
ids
=
this
.
convertIds
(
ids
);
ids
[
i
]
=
ids
[
i
].
toString
();
}
if
(
device
.
platform
!=
'iOS'
)
{
if
(
device
.
platform
!=
'iOS'
)
{
ids
=
ids
[
0
];
ids
=
ids
[
0
];
...
@@ -196,11 +194,11 @@ exports.cancel = function (ids, callback, scope) {
...
@@ -196,11 +194,11 @@ exports.cancel = function (ids, callback, scope) {
};
};
/**
/**
* Remove
s
all previously registered notifications.
* Remove all previously registered notifications.
*
*
* @param {Function} callback
* @param {Function} callback
* A function to be called after all notifications have been canceled
* A function to be called after all notifications have been canceled
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
cancelAll
=
function
(
callback
,
scope
)
{
exports
.
cancelAll
=
function
(
callback
,
scope
)
{
...
@@ -208,39 +206,55 @@ exports.cancelAll = function (callback, scope) {
...
@@ -208,39 +206,55 @@ exports.cancelAll = function (callback, scope) {
};
};
/**
/**
*
Retrieves a list with all currently pending notifications
.
*
Check if a notification with an ID is scheduled
.
*
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* @param {Function} callback
* A callback function to be called with the list
* A callback function to be called with the list
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
getScheduledIds
=
function
(
callback
,
scope
)
{
exports
.
isScheduled
=
function
(
id
,
callback
,
scope
)
{
this
.
exec
(
'getScheduledIds'
,
null
,
callback
,
scope
);
var
notId
=
(
id
||
'0'
).
toString
();
this
.
exec
(
'isScheduled'
,
notId
,
callback
,
scope
);
};
};
/**
/**
* Check
s wether a notification with an ID is schedul
ed.
* Check
if a notification with an ID was trigger
ed.
*
*
* @param {String} id
* @param {String} id
* The ID of the notification
* The ID of the notification
* @param {Function} callback
* @param {Function} callback
* A callback function to be called with the list
* A callback function to be called with the list
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
is
Schedul
ed
=
function
(
id
,
callback
,
scope
)
{
exports
.
is
Trigger
ed
=
function
(
id
,
callback
,
scope
)
{
var
notId
=
(
id
||
'0'
).
toString
();
var
notId
=
(
id
||
'0'
).
toString
();
this
.
exec
(
'is
Schedul
ed'
,
notId
,
callback
,
scope
);
this
.
exec
(
'is
Trigger
ed'
,
notId
,
callback
,
scope
);
};
};
/**
/**
*
Retrieves a list with all triggered
notifications.
*
List all currently pending
notifications.
*
*
* @param {Function} callback
* @param {Function} callback
* A callback function to be called with the list
* A callback function to be called with the list
* @param {Object} scope
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
getScheduledIds
=
function
(
callback
,
scope
)
{
this
.
exec
(
'getScheduledIds'
,
null
,
callback
,
scope
);
};
/**
* List all triggered notifications.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
getTriggeredIds
=
function
(
callback
,
scope
)
{
exports
.
getTriggeredIds
=
function
(
callback
,
scope
)
{
...
@@ -248,19 +262,89 @@ exports.getTriggeredIds = function (callback, scope) {
...
@@ -248,19 +262,89 @@ exports.getTriggeredIds = function (callback, scope) {
};
};
/**
/**
* Checks wether a notification with an ID was triggered.
* List all properties for given scheduled notifications.
* If called without IDs, all notification will be returned.
*
*
* @param {
String} id
* @param {
Number[]?} ids
*
The ID of the notification
*
Set of notification IDs
* @param {Function} callback
* @param {Function} callback
* A callback function to be called with the list
* A callback function to be called with the list
* @param {Object} scope
* @param {Object
?
} scope
* The scope for the callback function
* The scope for the callback function
*/
*/
exports
.
isTriggered
=
function
(
id
,
callback
,
scope
)
{
exports
.
getScheduled
=
function
(
)
{
var
notId
=
(
id
||
'0'
).
toString
(
);
var
args
=
Array
.
apply
(
null
,
arguments
);
this
.
exec
(
'isTriggered'
,
notId
,
callback
,
scope
);
if
(
typeof
args
[
0
]
==
'function'
)
{
args
.
unshift
([]);
}
var
ids
=
args
[
0
],
callback
=
args
[
1
],
scope
=
args
[
2
];
if
(
!
Array
.
isArray
(
ids
))
{
ids
=
[
ids
];
}
ids
=
this
.
convertIds
(
ids
);
this
.
exec
(
'getScheduled'
,
ids
,
callback
,
scope
);
};
/**
* Retrieve the properties for all scheduled notifications.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
getAllScheduled
=
function
(
callback
,
scope
)
{
this
.
exec
(
'getScheduled'
,
null
,
callback
,
scope
);
};
/**
* List all properties for given triggered notifications.
* If called without IDs, all notification will be returned.
*
* @param {Number[]?} ids
* Set of notification IDs
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
getTriggered
=
function
()
{
var
args
=
Array
.
apply
(
null
,
arguments
);
if
(
typeof
args
[
0
]
==
'function'
)
{
args
.
unshift
([]);
}
var
ids
=
args
[
0
],
callback
=
args
[
1
],
scope
=
args
[
2
];
if
(
!
Array
.
isArray
(
ids
))
{
ids
=
[
ids
];
}
ids
=
this
.
convertIds
(
ids
);
this
.
exec
(
'getTriggered'
,
ids
,
callback
,
scope
);
};
/**
* Retrieve the properties for all triggered notifications.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
getAllTriggered
=
function
(
callback
,
scope
)
{
this
.
exec
(
'getTriggered'
,
null
,
callback
,
scope
);
};
};
/**
/**
...
@@ -318,102 +402,6 @@ exports.promptForPermission = function (callback, scope) {
...
@@ -318,102 +402,6 @@ exports.promptForPermission = function (callback, scope) {
};
};
/**
/**
* Add new entries to the registry (more than one)
*
* @param {Object} options
* The notification properties
* @param {Function} callback
* A function to be called after the notification has been added
* @param {Object} scope
* The scope for the callback function
*
* @return {Number}
* The notification's ID
*/
exports
.
addMultiple
=
function
(
notifications
,
callback
,
scope
)
{
var
length
=
notifications
.
length
;
var
notificationsMerged
=
new
Array
(),
callbackFn
=
this
.
createCallbackFn
(
callback
,
scope
);
for
(
var
i
=
0
;
i
<
length
;
i
++
){
var
options
=
this
.
mergeWithDefaults
(
notifications
[
i
]);
if
(
options
.
id
)
{
options
.
id
=
options
.
id
.
toString
();
}
if
(
options
.
date
===
undefined
)
{
options
.
date
=
new
Date
();
}
if
(
options
.
title
)
{
options
.
title
=
options
.
title
.
toString
();
}
if
(
options
.
message
)
{
options
.
message
=
options
.
message
.
toString
();
}
if
(
typeof
options
.
date
==
'object'
)
{
options
.
date
=
Math
.
round
(
options
.
date
.
getTime
()
/
1000
);
}
if
([
'WinCE'
,
'Win32NT'
].
indexOf
(
device
.
platform
)
>
-
1
)
{
callbackFn
=
function
(
cmd
)
{
eval
(
cmd
);
};
}
notificationsMerged
.
push
(
options
);
}
cordova
.
exec
(
callbackFn
,
null
,
'LocalNotification'
,
'addMultiple'
,
notificationsMerged
);
return
options
.
id
;
};
/**
* Clear the specified notifications (more than one).
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* A function to be called after the notifications has been cleared.
* @param {Object} scope
* The scope for the callback function
*/
exports
.
clearMultiple
=
function
(
ids
,
callback
,
scope
)
{
var
length
=
ids
.
length
;
var
idArray
=
new
Array
(),
callbackFn
=
this
.
createCallbackFn
(
callback
,
scope
);
for
(
var
i
=
0
;
i
<
length
;
i
++
){
var
id
=
ids
[
i
].
toString
();
idArray
.
push
(
id
);
}
var
callbackFn
=
this
.
createCallbackFn
(
callback
,
scope
);
cordova
.
exec
(
callbackFn
,
null
,
'LocalNotification'
,
'clearMultiple'
,
[
ids
]);
};
/**
* Cancel the specified notifications (more than one).
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* A function to be called after the notifications has been canceled
* @param {Object} scope
* The scope for the callback function
*/
exports
.
cancelMultiple
=
function
(
ids
,
callback
,
scope
)
{
var
length
=
ids
.
length
;
var
idArray
=
new
Array
(),
callbackFn
=
this
.
createCallbackFn
(
callback
,
scope
);
for
(
var
i
=
0
;
i
<
length
;
i
++
){
var
id
=
ids
[
i
].
toString
();
idArray
.
push
(
id
);
}
var
callbackFn
=
this
.
createCallbackFn
(
callback
,
scope
);
cordova
.
exec
(
callbackFn
,
null
,
'LocalNotification'
,
'cancelMultiple'
,
[
ids
]);
};
/**
* Occurs when a notification was added.
* Occurs when a notification was added.
*
*
* @param {String} id
* @param {String} id
...
@@ -604,6 +592,25 @@ exports.createCallbackFn = function (callbackFn, scope) {
...
@@ -604,6 +592,25 @@ exports.createCallbackFn = function (callbackFn, scope) {
/**
/**
* @private
* @private
*
*
* Convert the IDs to Strings.
*
* @param {String/Number[]} ids
*
* @return Array of Strings
*/
exports
.
convertIds
=
function
(
ids
)
{
var
convertedIds
=
[];
for
(
var
i
=
0
;
i
<
ids
.
length
;
i
++
)
{
convertedIds
.
push
(
ids
[
i
].
toString
());
}
return
convertedIds
;
};
/**
* @private
*
* Executes the native counterpart.
* Executes the native counterpart.
*
*
* @param {String} action
* @param {String} action
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment