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
edbf05ed
Commit
edbf05ed
authored
Mar 14, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reimplement `getScheduledIds` and `isScheduled`
parent
c1f5ea43
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
14 deletions
+34
-14
APPLocalNotification.m
src/ios/APPLocalNotification.m
+34
-14
No files found.
src/ios/APPLocalNotification.m
View file @
edbf05ed
...
...
@@ -112,48 +112,68 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
/**
* Checks wether a notification with an ID is scheduled.
*/
*
* @param id
* The ID of the notification
* @param callback
* The callback function to be called with the result
*/
-
(
void
)
isScheduled
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
CDVPluginResult
*
result
;
NSArray
*
arguments
=
[
command
arguments
];
NSString
*
id
=
[
arguments
objectAtIndex
:
0
];
NSString
*
key
=
[
kAPP_LOCALNOTIFICATION
stringByAppendingString
:
id
];
NSData
*
data
=
[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
key
];
bool
isScheduled
=
data
!=
NULL
;
bool
isScheduled
=
NO
;
CDVPluginResult
*
result
;
NSArray
*
notifications
=
[[
UIApplication
sharedApplication
]
scheduledLocalNotifications
];
for
(
UILocalNotification
*
notification
in
notifications
)
{
NSString
*
notId
=
[
notification
.
userInfo
objectForKey
:
@"id"
];
if
([
notId
isEqualToString
:
id
])
{
isScheduled
=
YES
;
break
;
}
}
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsBool
:
isScheduled
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
}
/**
* Retrieves a list with all currently pending notifications.
* Retrieves a list of ids from all currently pending notifications.
*
* @param callback
* The callback function to be called with the result
*/
-
(
void
)
getScheduledIds
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSArray
*
notifications
=
[[
UIApplication
sharedApplication
]
scheduledLocalNotifications
];
NSMutableArray
*
scheduledIds
=
[[
NSMutableArray
alloc
]
init
];
NSDictionary
*
entries
=
[[
NSUserDefaults
standardUserDefaults
]
dictionaryRepresentation
];
CDVPluginResult
*
result
;
for
(
NSString
*
key
in
[
entries
allKeys
])
{
if
([
key
hasPrefix
:
kAPP_LOCALNOTIFICATION
])
for
(
UILocalNotification
*
notification
in
notifications
)
{
NSString
*
id
=
[
key
stringByReplacingOccurrencesOfString
:
kAPP_LOCALNOTIFICATION
withString
:
@"
"
];
NSString
*
id
=
[
notification
.
userInfo
objectForKey
:
@"id
"
];
[
scheduledIds
addObject
:
id
];
}
}
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsArray
:
scheduledIds
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
}
...
...
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