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
e0c0d588
Commit
e0c0d588
authored
Jan 15, 2015
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update example
parent
e071e96a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
508 additions
and
77 deletions
+508
-77
local-notification.js
...rdova.plugin.local-notification/www/local-notification.js
+94
-6
project.pbxproj
platforms/ios/NotificationExample.xcodeproj/project.pbxproj
+0
-0
UserInterfaceState.xcuserstate
...data/sebastian.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
Breakpoints_v2.xcbkptlist
...ebastian.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+34
-0
APPLocalNotification.m
....cordova.plugin.local-notification/APPLocalNotification.m
+0
-0
UIApplication+APPLocalNotification.m
...n.local-notification/UIApplication+APPLocalNotification.m
+0
-0
UILocalNotification+APPLocalNotification.m
...l-notification/UILocalNotification+APPLocalNotification.m
+0
-0
APPLocalNotification.h
....plugin.local-notification/src/ios/APPLocalNotification.h
+19
-8
APPLocalNotification.m
....plugin.local-notification/src/ios/APPLocalNotification.m
+80
-3
UIApplication+APPLocalNotification.h
...notification/src/ios/UIApplication+APPLocalNotification.h
+20
-7
UIApplication+APPLocalNotification.m
...notification/src/ios/UIApplication+APPLocalNotification.m
+131
-22
UILocalNotification+APPLocalNotification.h
...cation/src/ios/UILocalNotification+APPLocalNotification.h
+2
-0
UILocalNotification+APPLocalNotification.m
...cation/src/ios/UILocalNotification+APPLocalNotification.m
+34
-25
local-notification.js
...rdova.plugin.local-notification/www/local-notification.js
+94
-6
No files found.
platforms/android/assets/www/plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js
View file @
e0c0d588
...
...
@@ -67,7 +67,8 @@ exports._defaults = {
badge
:
-
1
,
id
:
'0'
,
json
:
''
,
repeat
:
''
repeat
:
''
,
date
:
undefined
};
...
...
@@ -208,6 +209,29 @@ exports.cancelAll = function (callback, scope) {
};
/**
* Check if a notification with an ID exists.
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
exist
=
function
(
id
,
callback
,
scope
)
{
var
notId
=
(
id
||
'0'
).
toString
();
this
.
exec
(
'exist'
,
notId
,
callback
,
scope
);
};
/**
* Alias for `exist`.
*/
exports
.
exists
=
function
()
{
this
.
exist
.
apply
(
this
,
arguments
);
};
/**
* Check if a notification with an ID is scheduled.
*
* @param {String} id
...
...
@@ -240,7 +264,26 @@ exports.isTriggered = function (id, callback, scope) {
};
/**
* List all currently pending notifications.
* List all local notification IDs.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
getAllIds
=
function
(
callback
,
scope
)
{
this
.
exec
(
'getAllIds'
,
null
,
callback
,
scope
);
};
/**
* Alias for `getAllIds`.
*/
exports
.
getIds
=
function
()
{
this
.
getAllIds
.
apply
(
this
,
arguments
);
};
/**
* List all scheduled notification IDs.
*
* @param {Function} callback
* A callback function to be called with the list
...
...
@@ -252,7 +295,7 @@ exports.getScheduledIds = function (callback, scope) {
};
/**
* List all triggered notifications.
* List all triggered notification
ID
s.
*
* @param {Function} callback
* A callback function to be called with the list
...
...
@@ -264,7 +307,50 @@ exports.getTriggeredIds = function (callback, scope) {
};
/**
* List all properties for given scheduled notifications.
* Property list for given local 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
.
get
=
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
(
'getAll'
,
ids
,
callback
,
scope
);
};
/**
* Property list for all local notifications.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
getAll
=
function
(
callback
,
scope
)
{
this
.
exec
(
'getAll'
,
null
,
callback
,
scope
);
};
/**
* Property list for given scheduled notifications.
* If called without IDs, all notification will be returned.
*
* @param {Number[]?} ids
...
...
@@ -307,7 +393,7 @@ exports.getAllScheduled = function (callback, scope) {
};
/**
*
List all properties
for given triggered notifications.
*
Property list
for given triggered notifications.
* If called without IDs, all notification will be returned.
*
* @param {Number[]?} ids
...
...
@@ -634,7 +720,9 @@ exports.convertIds = function (ids) {
exports
.
getValueFor
=
function
(
options
)
{
var
keys
=
Array
.
apply
(
null
,
arguments
).
slice
(
1
);
for
(
var
key
in
keys
)
{
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
var
key
=
keys
[
i
];
if
(
options
.
hasOwnProperty
(
key
))
{
return
options
[
key
];
}
...
...
platforms/ios/NotificationExample.xcodeproj/project.pbxproj
View file @
e0c0d588
This diff is collapsed.
Click to expand it.
platforms/ios/NotificationExample.xcodeproj/project.xcworkspace/xcuserdata/sebastian.xcuserdatad/UserInterfaceState.xcuserstate
View file @
e0c0d588
No preview for this file type
platforms/ios/NotificationExample.xcodeproj/xcuserdata/sebastian.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
e0c0d588
...
...
@@ -2,4 +2,38 @@
<Bucket
type =
"1"
version =
"2.0"
>
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"NotificationExample/Plugins/de.appplant.cordova.plugin.local-notification/APPLocalNotification.m"
timestampString =
"443052948.14449"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"332"
endingLineNumber =
"332"
landmarkName =
"-getScheduled:"
landmarkType =
"5"
>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"NotificationExample/Plugins/de.appplant.cordova.plugin.local-notification/CDVCommandDelegateImpl+APPLocalNotification.m"
timestampString =
"443053439.054207"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"76"
endingLineNumber =
"76"
landmarkName =
"-callSuccessFrom:withMessageAsArray:"
landmarkType =
"5"
>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
platforms/ios/NotificationExample/Plugins/de.appplant.cordova.plugin.local-notification/APPLocalNotification.m
View file @
e0c0d588
platforms/ios/NotificationExample/Plugins/de.appplant.cordova.plugin.local-notification/UIApplication+APPLocalNotification.m
View file @
e0c0d588
platforms/ios/NotificationExample/Plugins/de.appplant.cordova.plugin.local-notification/UILocalNotification+APPLocalNotification.m
View file @
e0c0d588
plugins/de.appplant.cordova.plugin.local-notification/src/ios/APPLocalNotification.h
View file @
e0c0d588
...
...
@@ -26,6 +26,12 @@
// Execute all queued events
-
(
void
)
deviceready
:(
CDVInvokedUrlCommand
*
)
command
;
// Inform if the app has the permission to show notifications
-
(
void
)
hasPermission
:(
CDVInvokedUrlCommand
*
)
command
;
// Register permission to show notifications
-
(
void
)
registerPermission
:(
CDVInvokedUrlCommand
*
)
command
;
// Schedule a new notification
-
(
void
)
add
:(
CDVInvokedUrlCommand
*
)
command
;
// Update a notification
...
...
@@ -34,21 +40,26 @@
-
(
void
)
cancel
:(
CDVInvokedUrlCommand
*
)
command
;
// Cancel all currently scheduled notifications
-
(
void
)
cancelAll
:(
CDVInvokedUrlCommand
*
)
command
;
// Check if a notification with an ID is scheduled
// If a notification with an ID exists
-
(
void
)
exist
:(
CDVInvokedUrlCommand
*
)
command
;
// If a notification with an ID was scheduled
-
(
void
)
isScheduled
:(
CDVInvokedUrlCommand
*
)
command
;
//
Check i
f a notification with an ID was triggered
//
I
f a notification with an ID was triggered
-
(
void
)
isTriggered
:(
CDVInvokedUrlCommand
*
)
command
;
// List all ids from all local notifications
-
(
void
)
getAllIds
:(
CDVInvokedUrlCommand
*
)
command
;
// List all ids from all pending notifications
-
(
void
)
getScheduledIds
:(
CDVInvokedUrlCommand
*
)
command
;
// List all ids from all triggered notifications
-
(
void
)
getTriggeredIds
:(
CDVInvokedUrlCommand
*
)
command
;
// List all properties for given scheduled notifications
// Property list for given local notifications
-
(
void
)
getAll
:(
CDVInvokedUrlCommand
*
)
command
;
// Property list for given scheduled notifications
-
(
void
)
getScheduled
:(
CDVInvokedUrlCommand
*
)
command
;
//
List all properties
for given triggered notifications
//
Property list
for given triggered notifications
-
(
void
)
getTriggered
:(
CDVInvokedUrlCommand
*
)
command
;
// Inform if the app has the permission to show notifications
-
(
void
)
hasPermission
:(
CDVInvokedUrlCommand
*
)
command
;
// Register permission to show notifications
-
(
void
)
registerPermission
:(
CDVInvokedUrlCommand
*
)
command
;
@end
plugins/de.appplant.cordova.plugin.local-notification/src/ios/APPLocalNotification.m
View file @
e0c0d588
...
...
@@ -162,6 +162,34 @@
}
/**
* If a notification by ID exists.
*
* @param id
* The ID of the notification
*/
-
(
void
)
exist
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSString
*
id
=
[[
command
arguments
]
objectAtIndex
:
0
];
CDVPluginResult
*
result
;
UILocalNotification
*
notification
;
notification
=
[[
UIApplication
sharedApplication
]
localNotificationWithId
:
id
];
bool
exists
=
notification
!=
NULL
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsBool
:
exists
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
}
/**
* If a notification by ID is scheduled.
*
* @param id
...
...
@@ -218,6 +246,26 @@
}
/**
* List all ids from all local notifications.
*/
-
(
void
)
getAllIds
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
CDVPluginResult
*
result
;
NSArray
*
notIds
;
notIds
=
[[
UIApplication
sharedApplication
]
localNotificationIds
];
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsArray
:
notIds
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
}
/**
* List all ids from all pending notifications.
*/
-
(
void
)
getScheduledIds
:(
CDVInvokedUrlCommand
*
)
command
...
...
@@ -258,7 +306,36 @@
}
/**
* List all properties for given scheduled notifications.
* Property list for given local notifications.
*
* @param ids
* The IDs of the notifications
*/
-
(
void
)
getAll
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSArray
*
ids
=
command
.
arguments
;
NSArray
*
notifications
;
CDVPluginResult
*
result
;
if
(
ids
.
count
==
0
)
{
notifications
=
[[
UIApplication
sharedApplication
]
localNotificationOptions
];
}
else
{
notifications
=
[[
UIApplication
sharedApplication
]
localNotificationOptions
:
ids
];
}
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsArray
:
notifications
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
}
/**
* Property list for given scheduled notifications.
*
* @param ids
* The IDs of the notifications
...
...
@@ -287,7 +364,7 @@
}
/**
*
List all properties
for given triggered notifications.
*
Property list
for given triggered notifications.
*
* @param ids
* The IDs of the notifications
...
...
@@ -613,7 +690,7 @@
}
js
=
[
NSString
stringWithFormat
:
@"setTimeout('
plugin
.notification.local.on%@(%@)',0)"
,
@"setTimeout('
cordova.plugins
.notification.local.on%@(%@)',0)"
,
event
,
params
];
if
(
deviceready
)
{
...
...
plugins/de.appplant.cordova.plugin.local-notification/src/ios/UIApplication+APPLocalNotification.h
View file @
e0c0d588
...
...
@@ -21,7 +21,11 @@
@interface
UIApplication
(
APPLocalNotification
)
@property
(
readonly
,
getter
=
localNotifications
)
NSArray
*
localNotifications
;
@property
(
readonly
,
getter
=
scheduledLocalNotifications2
)
NSArray
*
triggeredLocalNotifications2
;
@property
(
readonly
,
getter
=
triggeredLocalNotifications
)
NSArray
*
triggeredLocalNotifications
;
@property
(
readonly
,
getter
=
localNotificationIds
)
NSArray
*
localNotificationIds
;
@property
(
readonly
,
getter
=
triggeredLocalNotificationIds
)
NSArray
*
triggeredLocalNotificationIds
;
@property
(
readonly
,
getter
=
scheduledLocalNotificationIds
)
NSArray
*
scheduledLocalNotificationIds
;
...
...
@@ -29,17 +33,26 @@
-
(
BOOL
)
hasPermissionToScheduleLocalNotifications
;
// Ask for permission to schedule local notifications
-
(
void
)
registerPermissionToScheduleLocalNotifications
;
// Get the scheduled local notification by ID
// Get local notification by ID
-
(
UILocalNotification
*
)
localNotificationWithId
:(
NSString
*
)
id
;
// Get scheduled local notification by ID
-
(
UILocalNotification
*
)
scheduledLocalNotificationWithId
:(
NSString
*
)
id
;
// Get t
he t
riggered local notification by ID
// Get triggered local notification by ID
-
(
UILocalNotification
*
)
triggeredLocalNotificationWithId
:(
NSString
*
)
id
;
// List of properties from all scheduled notifications
// Property list from all local notifications
-
(
NSArray
*
)
localNotificationOptions
;
// Property list from all scheduled notifications
-
(
NSArray
*
)
scheduledLocalNotificationOptions
;
// List of properties from given scheduled notifications
-
(
NSArray
*
)
scheduledLocalNotificationOptions
:(
NSArray
*
)
ids
;
// List of properties from all triggered notifications
// Property list from all triggered notifications
-
(
NSArray
*
)
triggeredLocalNotificationOptions
;
// List of properties from given triggered notifications
// Property list from given local notifications
-
(
NSArray
*
)
localNotificationOptions
:(
NSArray
*
)
ids
;
// Property list from given scheduled notifications
-
(
NSArray
*
)
scheduledLocalNotificationOptions
:(
NSArray
*
)
ids
;
// Property list from given triggered notifications
-
(
NSArray
*
)
triggeredLocalNotificationOptions
:(
NSArray
*
)
ids
;
@end
plugins/de.appplant.cordova.plugin.local-notification/src/ios/UIApplication+APPLocalNotification.m
View file @
e0c0d588
...
...
@@ -72,18 +72,55 @@
#pragma mark LocalNotifications
/**
* List of all local notifications which have been added
* but not yet removed from the notification center.
*/
-
(
NSArray
*
)
localNotifications
{
NSArray
*
scheduledNotifications
=
self
.
scheduledLocalNotifications
;
NSMutableArray
*
notifications
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
scheduledNotifications
)
{
if
(
notification
)
{
[
notifications
addObject
:
notification
];
}
}
return
notifications
;
}
/**
* List of all local notifications which have been scheduled
* and not yet removed from the notification center.
*/
-
(
NSArray
*
)
scheduledLocalNotifications2
{
NSArray
*
scheduledNotifications
=
self
.
scheduledLocalNotifications
;
NSMutableArray
*
notifications
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
scheduledNotifications
)
{
if
(
notification
&&
[
notification
wasScheduled
])
{
[
notifications
addObject
:
notification
];
}
}
return
notifications
;
}
/**
* List of all triggered local notifications which have been scheduled
* and not yet removed the notification center.
*/
-
(
NSArray
*
)
triggeredLocalNotifications
{
NSArray
*
scheduledNotifications
=
self
.
scheduledL
ocalNotifications
;
NSArray
*
notifications
=
self
.
l
ocalNotifications
;
NSMutableArray
*
triggeredNotifications
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
scheduledNotifications
)
{
if
(
notification
&&
[
notification
wasTriggered
])
for
(
UILocalNotification
*
notification
in
notifications
)
{
if
([
notification
wasTriggered
])
{
[
triggeredNotifications
addObject
:
notification
];
}
}
...
...
@@ -93,7 +130,24 @@
/**
* List of all triggered local notifications IDs which have been scheduled
* and not yet removed the notification center.
* and not yet removed from the notification center.
*/
-
(
NSArray
*
)
localNotificationIds
{
NSArray
*
notifications
=
self
.
localNotifications
;
NSMutableArray
*
ids
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
notifications
)
{
[
ids
addObject
:
notification
.
options
.
id
];
}
return
ids
;
}
/**
* List of all added local notifications IDs which have been scheduled
* and not yet removed from the notification center.
*/
-
(
NSArray
*
)
triggeredLocalNotificationIds
{
...
...
@@ -113,32 +167,50 @@
*/
-
(
NSArray
*
)
scheduledLocalNotificationIds
{
NSArray
*
notifications
=
self
.
scheduledLocalNotifications
;
NSArray
*
notifications
=
self
.
scheduledLocalNotifications
2
;
NSMutableArray
*
ids
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
notifications
)
{
if
(
notification
)
{
[
ids
addObject
:
notification
.
options
.
id
];
}
}
return
ids
;
}
/**
* Get the scheduled local notification by ID.
* Get local notification by ID.
*
* @param id
* Notification ID
*/
-
(
UILocalNotification
*
)
localNotificationWithId
:
(
NSString
*
)
id
{
NSArray
*
notifications
=
self
.
localNotifications
;
for
(
UILocalNotification
*
notification
in
notifications
)
{
if
([
notification
.
options
.
id
isEqualToString
:
id
])
{
return
notification
;
}
}
return
NULL
;
}
/**
* Get scheduled local notification by ID.
*
* @param id
* Notification ID
*/
-
(
UILocalNotification
*
)
scheduledLocalNotificationWithId
:
(
NSString
*
)
id
{
NSArray
*
notifications
=
self
.
scheduledLocalNotifications
;
NSArray
*
notifications
=
self
.
scheduledLocalNotifications
2
;
for
(
UILocalNotification
*
notification
in
notifications
)
{
if
(
notification
&&
[
notification
.
options
.
id
isEqualToString
:
id
])
{
if
([
notification
.
options
.
id
isEqualToString
:
id
])
{
return
notification
;
}
}
...
...
@@ -147,14 +219,14 @@
}
/**
* Get t
he t
riggered local notification by ID.
* Get triggered local notification by ID.
*
* @param id
* Notification ID
*/
-
(
UILocalNotification
*
)
triggeredLocalNotificationWithId
:
(
NSString
*
)
id
{
UILocalNotification
*
notification
=
[
self
scheduledL
ocalNotificationWithId
:
id
];
UILocalNotification
*
notification
=
[
self
l
ocalNotificationWithId
:
id
];
if
(
notification
&&
[
notification
wasTriggered
])
{
return
notification
;
...
...
@@ -164,37 +236,67 @@
}
/**
* List of properties from all notifications.
*/
-
(
NSArray
*
)
localNotificationOptions
{
NSArray
*
notifications
=
self
.
localNotifications
;
NSMutableArray
*
options
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
notifications
)
{
[
options
addObject
:
notification
.
userInfo
];
}
return
options
;
}
/**
* List of properties from all scheduled notifications.
*/
-
(
NSArray
*
)
scheduledLocalNotificationOptions
{
NSArray
*
notifications
=
self
.
scheduledLocalNotifications
;
NSArray
*
notifications
=
[
self
scheduledLocalNotifications2
]
;
NSMutableArray
*
options
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
notifications
)
{
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
scheduled
notifications.
* List of properties from given
local
notifications.
*
* @param ids
* Notification IDs
*/
-
(
NSArray
*
)
scheduledL
ocalNotificationOptions
:
(
NSArray
*
)
ids
-
(
NSArray
*
)
l
ocalNotificationOptions
:
(
NSArray
*
)
ids
{
UILocalNotification
*
notification
;
NSMutableArray
*
options
=
[[
NSMutableArray
alloc
]
init
];
for
(
NSString
*
id
in
ids
)
{
notification
=
[
self
scheduledL
ocalNotificationWithId
:
id
];
notification
=
[
self
l
ocalNotificationWithId
:
id
];
if
(
notification
)
{
[
options
addObject
:
notification
.
userInfo
];
...
...
@@ -205,17 +307,24 @@
}
/**
* List of properties from all triggered notifications.
* List of properties from given scheduled notifications.
*
* @param ids
* Notification IDs
*/
-
(
NSArray
*
)
triggeredLocalNotificationOption
s
-
(
NSArray
*
)
scheduledLocalNotificationOptions
:
(
NSArray
*
)
id
s
{
NSArray
*
notifications
=
self
.
triggeredLocalNotifications
;
UILocalNotification
*
notification
;
NSMutableArray
*
options
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
notification
s
)
for
(
NSString
*
id
in
id
s
)
{
notification
=
[
self
scheduledLocalNotificationWithId
:
id
];
if
(
notification
)
{
[
options
addObject
:
notification
.
userInfo
];
}
}
return
options
;
}
...
...
plugins/de.appplant.cordova.plugin.local-notification/src/ios/UILocalNotification+APPLocalNotification.h
View file @
e0c0d588
...
...
@@ -31,6 +31,8 @@
-
(
double
)
timeIntervalSinceFireDate
;
// If the fire date was in the past
-
(
BOOL
)
wasInThePast
;
// If the notification was already scheduled
-
(
BOOL
)
wasScheduled
;
// If the notification was already triggered
-
(
BOOL
)
wasTriggered
;
// If the notification was updated
...
...
plugins/de.appplant.cordova.plugin.local-notification/src/ios/UILocalNotification+APPLocalNotification.m
View file @
e0c0d588
...
...
@@ -143,6 +143,32 @@ static char optionsKey;
}
/**
* Encode the user info dict to JSON.
*/
-
(
NSString
*
)
encodeToJSON
{
NSString
*
json
;
NSData
*
data
;
NSMutableDictionary
*
obj
=
[
self
.
userInfo
mutableCopy
];
[
obj
removeObjectForKey
:
@"json"
];
[
obj
removeObjectForKey
:
@"updatedAt"
];
data
=
[
NSJSONSerialization
dataWithJSONObject
:
obj
options
:
NSJSONWritingPrettyPrinted
error
:
Nil
];
json
=
[[
NSString
alloc
]
initWithData
:
data
encoding
:
NSUTF8StringEncoding
];
return
[
json
stringByReplacingOccurrencesOfString
:
@"
\n
"
withString
:
@""
];
}
#pragma mark -
#pragma mark State
/**
* If the fire date was in the past.
*/
-
(
BOOL
)
wasInThePast
...
...
@@ -150,6 +176,12 @@ static char optionsKey;
return
[
self
timeIntervalSinceFireDate
]
>
0
;
}
// If the notification was already scheduled
-
(
BOOL
)
wasScheduled
{
return
[
self
isRepeating
]
||
!
[
self
wasInThePast
];
}
/**
* If the notification was already triggered.
*/
...
...
@@ -158,9 +190,9 @@ static char optionsKey;
NSDate
*
now
=
[
NSDate
date
];
NSDate
*
fireDate
=
self
.
fireDate
;
bool
isLaterThan
OrEqualTo
=
!
([
now
compare
:
fireDate
]
==
NSOrderedAscending
);
bool
isLaterThan
FireDate
=
!
([
now
compare
:
fireDate
]
==
NSOrderedAscending
);
return
isLaterThan
OrEqualTo
;
return
isLaterThan
FireDate
;
}
/**
...
...
@@ -187,27 +219,4 @@ static char optionsKey;
return
[
self
.
options
isRepeating
];
}
/**
* Encode the user info dict to JSON.
*/
-
(
NSString
*
)
encodeToJSON
{
NSString
*
json
;
NSData
*
data
;
NSMutableDictionary
*
obj
=
[
self
.
userInfo
mutableCopy
];
[
obj
removeObjectForKey
:
@"json"
];
[
obj
removeObjectForKey
:
@"updatedAt"
];
data
=
[
NSJSONSerialization
dataWithJSONObject
:
obj
options
:
NSJSONWritingPrettyPrinted
error
:
Nil
];
json
=
[[
NSString
alloc
]
initWithData
:
data
encoding
:
NSUTF8StringEncoding
];
return
[
json
stringByReplacingOccurrencesOfString
:
@"
\n
"
withString
:
@""
];
}
@end
plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js
View file @
e0c0d588
...
...
@@ -67,7 +67,8 @@ exports._defaults = {
badge
:
-
1
,
id
:
'0'
,
json
:
''
,
repeat
:
''
repeat
:
''
,
date
:
undefined
};
...
...
@@ -208,6 +209,29 @@ exports.cancelAll = function (callback, scope) {
};
/**
* Check if a notification with an ID exists.
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
exist
=
function
(
id
,
callback
,
scope
)
{
var
notId
=
(
id
||
'0'
).
toString
();
this
.
exec
(
'exist'
,
notId
,
callback
,
scope
);
};
/**
* Alias for `exist`.
*/
exports
.
exists
=
function
()
{
this
.
exist
.
apply
(
this
,
arguments
);
};
/**
* Check if a notification with an ID is scheduled.
*
* @param {String} id
...
...
@@ -240,7 +264,26 @@ exports.isTriggered = function (id, callback, scope) {
};
/**
* List all currently pending notifications.
* List all local notification IDs.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
getAllIds
=
function
(
callback
,
scope
)
{
this
.
exec
(
'getAllIds'
,
null
,
callback
,
scope
);
};
/**
* Alias for `getAllIds`.
*/
exports
.
getIds
=
function
()
{
this
.
getAllIds
.
apply
(
this
,
arguments
);
};
/**
* List all scheduled notification IDs.
*
* @param {Function} callback
* A callback function to be called with the list
...
...
@@ -252,7 +295,7 @@ exports.getScheduledIds = function (callback, scope) {
};
/**
* List all triggered notifications.
* List all triggered notification
ID
s.
*
* @param {Function} callback
* A callback function to be called with the list
...
...
@@ -264,7 +307,50 @@ exports.getTriggeredIds = function (callback, scope) {
};
/**
* List all properties for given scheduled notifications.
* Property list for given local 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
.
get
=
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
(
'getAll'
,
ids
,
callback
,
scope
);
};
/**
* Property list for all local notifications.
*
* @param {Function} callback
* A callback function to be called with the list
* @param {Object?} scope
* The scope for the callback function
*/
exports
.
getAll
=
function
(
callback
,
scope
)
{
this
.
exec
(
'getAll'
,
null
,
callback
,
scope
);
};
/**
* Property list for given scheduled notifications.
* If called without IDs, all notification will be returned.
*
* @param {Number[]?} ids
...
...
@@ -307,7 +393,7 @@ exports.getAllScheduled = function (callback, scope) {
};
/**
*
List all properties
for given triggered notifications.
*
Property list
for given triggered notifications.
* If called without IDs, all notification will be returned.
*
* @param {Number[]?} ids
...
...
@@ -634,7 +720,9 @@ exports.convertIds = function (ids) {
exports
.
getValueFor
=
function
(
options
)
{
var
keys
=
Array
.
apply
(
null
,
arguments
).
slice
(
1
);
for
(
var
key
in
keys
)
{
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
var
key
=
keys
[
i
];
if
(
options
.
hasOwnProperty
(
key
))
{
return
options
[
key
];
}
...
...
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