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
Expand all
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 @@
-
(
void
)
isScheduled
:(
CDVInvokedUrlCommand
*
)
command
;
// Check if a notification with an ID was triggered
-
(
void
)
isTriggered
:(
CDVInvokedUrlCommand
*
)
command
;
//
Retrieve a list of
ids from all pending notifications
//
List all
ids from all pending notifications
-
(
void
)
getScheduledIds
:(
CDVInvokedUrlCommand
*
)
command
;
//
Retrieve a list of
ids from all triggered notifications
//
List all
ids from all triggered notifications
-
(
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
-
(
void
)
hasPermission
:(
CDVInvokedUrlCommand
*
)
command
;
// Register permission to show notifications
...
...
src/ios/APPLocalNotification.m
View file @
8418c152
...
...
@@ -117,7 +117,7 @@
}
/**
* Cancel
s
all currently scheduled notifications.
* Cancel all currently scheduled notifications.
*/
-
(
void
)
cancelAll
:(
CDVInvokedUrlCommand
*
)
command
{
...
...
@@ -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
{
...
...
@@ -177,27 +205,48 @@
}
/**
* Checks wether a notification with an ID was triggered.
*
* @param id
* The ID of the notification
* List all ids from all triggered notifications.
*/
-
(
void
)
isTriggered
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
getTriggeredIds
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSString
*
id
=
[[
command
arguments
]
objectAtIndex
:
0
];
CDVPluginResult
*
result
;
UILocalNotification
*
notification
;
NSArray
*
triggeredIds
;
notification
=
[[
UIApplication
sharedApplication
]
triggeredLocalNotification
WithId
:
id
];
triggeredIds
=
[[
UIApplication
sharedApplication
]
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
messageAsBool
:
isTriggered
];
messageAsArray
:
notifications
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
...
...
@@ -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
:
^
{
NSArray
*
ids
=
command
.
arguments
;
NSArray
*
notifications
;
CDVPluginResult
*
result
;
NSArray
*
triggeredIds
;
triggeredIds
=
[[
UIApplication
sharedApplication
]
triggeredLocalNotificationIds
];
if
(
ids
.
count
==
0
)
{
notifications
=
[[
UIApplication
sharedApplication
]
triggeredLocalNotificationOptions
];
}
else
{
notifications
=
[[
UIApplication
sharedApplication
]
triggeredLocalNotificationOptions
:
ids
];
}
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsArray
:
triggeredId
s
];
messageAsArray
:
notification
s
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
...
...
src/ios/UIApplication+APPLocalNotification.h
View file @
8418c152
...
...
@@ -33,5 +33,13 @@
-
(
UILocalNotification
*
)
scheduledLocalNotificationWithId
:(
NSString
*
)
id
;
// Get the triggered local notification by 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
src/ios/UIApplication+APPLocalNotification.m
View file @
8418c152
...
...
@@ -97,15 +97,15 @@
*/
-
(
NSArray
*
)
triggeredLocalNotificationIds
{
NSArray
*
triggeredN
otifications
=
self
.
triggeredLocalNotifications
;
NSMutableArray
*
triggeredNotificationI
ds
=
[[
NSMutableArray
alloc
]
init
];
NSArray
*
n
otifications
=
self
.
triggeredLocalNotifications
;
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 @@
*/
-
(
NSArray
*
)
scheduledLocalNotificationIds
{
NSArray
*
scheduledN
otifications
=
self
.
scheduledLocalNotifications
;
NSMutableArray
*
scheduledNotificationI
ds
=
[[
NSMutableArray
alloc
]
init
];
NSArray
*
n
otifications
=
self
.
scheduledLocalNotifications
;
NSMutableArray
*
i
ds
=
[[
NSMutableArray
alloc
]
init
];
for
(
UILocalNotification
*
notification
in
scheduledN
otifications
)
for
(
UILocalNotification
*
notification
in
n
otifications
)
{
if
(
notification
)
{
[
scheduledNotificationIds
addObject
:
notification
.
options
.
id
];
if
(
notification
)
{
[
ids
addObject
:
notification
.
options
.
id
];
}
}
return
scheduledNotificationI
ds
;
return
i
ds
;
}
/**
* Get the scheduled local notification by ID.
*
* @param id
* Notification ID
*/
-
(
UILocalNotification
*
)
scheduledLocalNotificationWithId
:
(
NSString
*
)
id
{
...
...
@@ -136,8 +138,7 @@
for
(
UILocalNotification
*
notification
in
notifications
)
{
if
(
notification
&&
[
notification
.
options
.
id
isEqualToString
:
id
])
{
if
(
notification
&&
[
notification
.
options
.
id
isEqualToString
:
id
])
{
return
notification
;
}
}
...
...
@@ -147,6 +148,9 @@
/**
* Get the triggered local notification by ID.
*
* @param id
* Notification ID
*/
-
(
UILocalNotification
*
)
triggeredLocalNotificationWithId
:
(
NSString
*
)
id
{
...
...
@@ -159,4 +163,84 @@
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
www/local-notification.js
View file @
8418c152
This diff is collapsed.
Click to expand it.
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