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
f2fb5e10
Commit
f2fb5e10
authored
Feb 20, 2018
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internal code changes
parent
3cb3b51e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
162 deletions
+113
-162
LocalNotification.java
src/android/LocalNotification.java
+0
-0
APPLocalNotification.h
src/ios/APPLocalNotification.h
+4
-26
APPLocalNotification.m
src/ios/APPLocalNotification.m
+53
-101
UNUserNotificationCenter+APPLocalNotification.m
src/ios/UNUserNotificationCenter+APPLocalNotification.m
+46
-25
local-notification.js
www/local-notification.js
+10
-10
No files found.
src/android/LocalNotification.java
View file @
f2fb5e10
This diff is collapsed.
Click to expand it.
src/ios/APPLocalNotification.h
View file @
f2fb5e10
...
...
@@ -25,50 +25,28 @@
@interface
APPLocalNotification
:
CDVPlugin
<
UNUserNotificationCenterDelegate
>
// Set launchDetails object
-
(
void
)
launch
:
(
CDVInvokedUrlCommand
*
)
command
;
// Execute all queued events
-
(
void
)
ready
:(
CDVInvokedUrlCommand
*
)
command
;
// Check permission to show notifications
-
(
void
)
actions
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
check
:(
CDVInvokedUrlCommand
*
)
command
;
// Request permission to show notifications
-
(
void
)
request
:(
CDVInvokedUrlCommand
*
)
command
;
// Register/update an action group
-
(
void
)
actions
:(
CDVInvokedUrlCommand
*
)
command
;
// Schedule notifications
-
(
void
)
schedule
:(
CDVInvokedUrlCommand
*
)
command
;
// Update set of notifications
-
(
void
)
update
:(
CDVInvokedUrlCommand
*
)
command
;
// Clear notifications by id
-
(
void
)
clear
:(
CDVInvokedUrlCommand
*
)
command
;
// Clear all notifications
-
(
void
)
clearAll
:(
CDVInvokedUrlCommand
*
)
command
;
// Cancel notifications by id
-
(
void
)
cancel
:(
CDVInvokedUrlCommand
*
)
command
;
// Cancel all notifications
-
(
void
)
cancelAll
:(
CDVInvokedUrlCommand
*
)
command
;
// Notification type
-
(
void
)
type
:(
CDVInvokedUrlCommand
*
)
command
;
// List of all notification IDs
-
(
void
)
ids
:(
CDVInvokedUrlCommand
*
)
command
;
// List of all scheduled notification IDs
-
(
void
)
scheduledIds
:(
CDVInvokedUrlCommand
*
)
command
;
// List of all triggered notification IDs
-
(
void
)
triggeredIds
:(
CDVInvokedUrlCommand
*
)
command
;
// Notification by id
-
(
void
)
notification
:(
CDVInvokedUrlCommand
*
)
command
;
// List of notifications by id
-
(
void
)
notifications
:(
CDVInvokedUrlCommand
*
)
command
;
// List of scheduled notifications by id
-
(
void
)
scheduledNotifications
:(
CDVInvokedUrlCommand
*
)
command
;
// List of triggered notifications by id
-
(
void
)
triggeredNotifications
:(
CDVInvokedUrlCommand
*
)
command
;
@end
src/ios/APPLocalNotification.m
View file @
f2fb5e10
...
...
@@ -258,52 +258,34 @@ UNNotificationPresentationOptions const OptionAlert = UNNotificationPresentation
}
/**
* List of
all notification IDs
.
* List of
notification IDs by type
.
*
* @return [ Void ]
*/
-
(
void
)
ids
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
ids
:
command
byType
:
NotifcationTypeAll
];
}
/**
* List of all scheduled notification IDs.
*
* @return [ Void ]
*/
-
(
void
)
scheduledIds
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
ids
:
command
byType
:
NotifcationTypeScheduled
];
}
/**
* List of all triggered notification IDs.
*
* @return [ Void ]
*/
-
(
void
)
triggeredIds
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
ids
:
command
byType
:
NotifcationTypeTriggered
];
}
/**
* List of ids for given local notifications.
*
* @param [ APPNotificationType ] type The type of notifications to look for.
*
* @return [ Void ]
*/
-
(
void
)
ids
:(
CDVInvokedUrlCommand
*
)
command
byType
:(
APPNotificationType
)
type
;
{
[
self
.
commandDelegate
runInBackground
:
^
{
int
code
=
[
command
.
arguments
[
0
]
intValue
];
APPNotificationType
type
=
NotifcationTypeUnknown
;
switch
(
code
)
{
case
0
:
type
=
NotifcationTypeAll
;
break
;
case
1
:
type
=
NotifcationTypeScheduled
;
break
;
case
2
:
type
=
NotifcationTypeTriggered
;
break
;
}
NSArray
*
ids
=
[
_center
getNotificationIdsByType
:
type
];
CDVPluginResult
*
result
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsArray
:
ids
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
...
...
@@ -342,58 +324,36 @@ UNNotificationPresentationOptions const OptionAlert = UNNotificationPresentation
*/
-
(
void
)
notifications
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
notifications
:
command
byType
:
NotifcationTypeAll
];
}
/**
* List of scheduled notifications by id.
*
* @param [ Array<Number> ] ids The ids of the notifications to return.
*
* @return [ Void ]
*/
-
(
void
)
scheduledNotifications
:
(
CDVInvokedUrlCommand
*
)
command
{
[
self
notifications
:
command
byType
:
NotifcationTypeScheduled
];
}
/**
* List of triggered notifications by id.
*
* @param [ Array<Number> ] ids The ids of the notifications to return.
*
* @return [ Void ]
*/
-
(
void
)
triggeredNotifications
:
(
CDVInvokedUrlCommand
*
)
command
{
[
self
notifications
:
command
byType
:
NotifcationTypeTriggered
];
}
/**
* List of notifications by type or id.
*
* @param [ APPNotificationType ] type The type of notifications to look for.
*
* @return [ Void ]
*/
-
(
void
)
notifications
:
(
CDVInvokedUrlCommand
*
)
command
byType
:
(
APPNotificationType
)
type
;
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSArray
*
ids
=
command
.
arguments
;
NSArray
*
notifications
;
if
(
ids
.
count
>
0
)
{
notifications
=
[
_center
getNotificationOptionsById
:
ids
];
int
code
=
[
command
.
arguments
[
0
]
intValue
];
APPNotificationType
type
=
NotifcationTypeUnknown
;
NSArray
*
toasts
;
NSArray
*
ids
;
switch
(
code
)
{
case
0
:
type
=
NotifcationTypeAll
;
break
;
case
1
:
type
=
NotifcationTypeScheduled
;
break
;
case
2
:
type
=
NotifcationTypeTriggered
;
break
;
case
3
:
ids
=
command
.
arguments
[
1
];
toasts
=
[
_center
getNotificationOptionsById
:
ids
];
break
;
}
else
{
notifications
=
[
_center
getNotificationOptionsByType
:
type
];
if
(
toasts
==
nil
)
{
toasts
=
[
_center
getNotificationOptionsByType
:
type
];
}
CDVPluginResult
*
result
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsArray
:
notification
s
];
messageAsArray
:
toast
s
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
...
...
@@ -438,35 +398,27 @@ UNNotificationPresentationOptions const OptionAlert = UNNotificationPresentation
-
(
void
)
actions
:(
CDVInvokedUrlCommand
*
)
command
{
[
self
.
commandDelegate
runInBackground
:
^
{
int
task
=
[
command
.
arguments
[
0
]
intValue
];
int
code
=
[
command
.
arguments
[
0
]
intValue
];
NSString
*
identifier
=
[
command
argumentAtIndex
:
1
];
NSDictionary
*
options
=
[
command
argumentAtIndex
:
2
];
APPNotificationContent
*
notification
;
NSDictionary
*
options
;
NSString
*
identifier
;
BOOL
found
;
switch
(
task
)
{
case
1
:
options
=
command
.
arguments
[
1
];
switch
(
code
)
{
case
0
:
notification
=
[[
APPNotificationContent
alloc
]
initWithOptions
:
options
];
[
_center
addActionGroup
:
notification
.
category
];
[
self
execCallback
:
command
];
break
;
case
-
1
:
identifier
=
command
.
arguments
[
1
];
case
1
:
[
_center
removeActionGroup
:
identifier
];
[
self
execCallback
:
command
];
break
;
case
0
:
identifier
=
command
.
arguments
[
1
];
case
2
:
found
=
[
_center
hasActionGroup
:
identifier
];
[
self
execCallback
:
command
arg
:
found
];
break
;
}
}];
...
...
@@ -667,7 +619,7 @@ UNNotificationPresentationOptions const OptionAlert = UNNotificationPresentation
CDVPluginResult
*
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsBool
:
arg
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}
...
...
src/ios/UNUserNotificationCenter+APPLocalNotification.m
View file @
f2fb5e10
...
...
@@ -106,7 +106,7 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
*
* @param [ NSString* ] identifier The category id to check for.
*
* @return [
Void
]
* @return [
BOOL
]
*/
-
(
BOOL
)
hasActionGroup
:
(
NSString
*
)
identifier
{
...
...
@@ -134,6 +134,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of all delivered or still pending notifications.
*
* @return [ NSArray<UNNotificationRequest*>* ]
*/
-
(
NSArray
*
)
getNotifications
{
...
...
@@ -147,6 +149,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of all triggered notifications.
*
* @return [ NSArray<UNNotificationRequest*>* ]
*/
-
(
NSArray
*
)
getDeliveredNotifications
{
...
...
@@ -168,6 +172,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of all pending notifications.
*
* @return [ NSArray<UNNotificationRequest*>* ]
*/
-
(
NSArray
*
)
getPendingNotifications
{
...
...
@@ -187,8 +193,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of all notifications from given type.
*
* @param type
* Notification life cycle type
* @param [ APPNotificationType ] type Notification life cycle type.
*
* @return [ NSArray<UNNotificationRequest>* ]
*/
-
(
NSArray
*
)
getNotificationsByType
:
(
APPNotificationType
)
type
{
...
...
@@ -206,6 +213,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of all local notifications IDs.
*
* @return [ NSArray<int>* ]
*/
-
(
NSArray
*
)
getNotificationIds
{
...
...
@@ -223,8 +232,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of all notifications IDs from given type.
*
* @param type
* Notification life cycle type
* @param [ APPNotificationType ] type Notification life cycle type.
*
* @return [ NSArray<int>* ]
*/
-
(
NSArray
*
)
getNotificationIdsByType
:
(
APPNotificationType
)
type
{
...
...
@@ -242,8 +252,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* Find notification by ID.
*
* @param id
* Notification ID
* @param id Notification ID
*
* @return [ UNNotificationRequest* ]
*/
-
(
UNNotificationRequest
*
)
getNotificationWithId
:
(
NSNumber
*
)
id
{
...
...
@@ -262,7 +273,11 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
}
/**
* Find notification type by ID
* Find notification type by ID.
*
* @param [ NSNumber* ] id The ID of the notification.
*
* @return [ APPNotificationType ]
*/
-
(
APPNotificationType
)
getTypeOfNotificationWithId
:
(
NSNumber
*
)
id
{
...
...
@@ -281,6 +296,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of properties from all notifications.
*
* @return [ NSArray<APPNotificationOptions*>* ]
*/
-
(
NSArray
*
)
getNotificationOptions
{
...
...
@@ -290,8 +307,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of properties from all notifications of given type.
*
* @param type
* Notification life cycle type
* @param [ APPNotificationType ] type Notification life cycle type.
*
* @return [ NSArray<APPNotificationOptions*>* ]
*/
-
(
NSArray
*
)
getNotificationOptionsByType
:
(
APPNotificationType
)
type
{
...
...
@@ -309,8 +327,9 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/**
* List of properties from given local notifications.
*
* @param ids
* Notification IDs
* @param [ NSArray<int> ] ids The ids of the notifications to find.
*
* @return [ NSArray<APPNotificationOptions*>* ]
*/
-
(
NSArray
*
)
getNotificationOptionsById
:
(
NSArray
*
)
ids
{
...
...
@@ -329,6 +348,8 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/*
* Clear all notfications.
*
* @return [ Void ]
*/
-
(
void
)
clearNotifications
{
...
...
@@ -338,19 +359,19 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/*
* Clear Specified notfication.
*
* @param notification
* The notification object
* @param [ UNNotificationRequest* ] notification The notification object.
*
* @return [ Void ]
*/
-
(
void
)
clearNotification
:
(
UNNotificationRequest
*
)
notification
-
(
void
)
clearNotification
:
(
UNNotificationRequest
*
)
toast
{
NSArray
*
ids
=
[[
NSArray
alloc
]
initWithObjects
:
notification
.
identifier
,
nil
];
[
self
removeDeliveredNotificationsWithIdentifiers
:
ids
];
[
self
removeDeliveredNotificationsWithIdentifiers
:@[
toast
.
identifier
]];
}
/*
* Cancel all notfications.
*
* @return [ Void ]
*/
-
(
void
)
cancelNotifications
{
...
...
@@ -361,14 +382,14 @@ NSString * const kAPPGeneralCategory = @"GENERAL";
/*
* Cancel specified notfication.
*
* @param notification
* The notification object
* @param [ UNNotificationRequest* ] notification The notification object.
*
* @return [ Void ]
*/
-
(
void
)
cancelNotification
:
(
UNNotificationRequest
*
)
notification
-
(
void
)
cancelNotification
:
(
UNNotificationRequest
*
)
toast
{
NSArray
*
ids
=
[[
NSArray
alloc
]
initWithObjects
:
notification
.
identifier
,
nil
];
NSArray
*
ids
=
@[
toast
.
identifier
];
[
self
removeDeliveredNotificationsWithIdentifiers
:
ids
];
[
self
removePendingNotificationRequestsWithIdentifiers
:
ids
];
}
...
...
www/local-notification.js
View file @
f2fb5e10
...
...
@@ -292,7 +292,7 @@ exports.getType = function (id, callback, scope) {
* @return [ Void ]
*/
exports
.
getIds
=
function
(
callback
,
scope
)
{
this
.
_exec
(
'ids'
,
null
,
callback
,
scope
);
this
.
_exec
(
'ids'
,
0
,
callback
,
scope
);
};
/**
...
...
@@ -304,7 +304,7 @@ exports.getIds = function (callback, scope) {
* @return [ Void ]
*/
exports
.
getScheduledIds
=
function
(
callback
,
scope
)
{
this
.
_exec
(
'
scheduledIds'
,
null
,
callback
,
scope
);
this
.
_exec
(
'
ids'
,
1
,
callback
,
scope
);
};
/**
...
...
@@ -316,7 +316,7 @@ exports.getScheduledIds = function (callback, scope) {
* @return [ Void ]
*/
exports
.
getTriggeredIds
=
function
(
callback
,
scope
)
{
this
.
_exec
(
'
triggeredIds'
,
null
,
callback
,
scope
);
this
.
_exec
(
'
ids'
,
2
,
callback
,
scope
);
};
/**
...
...
@@ -347,7 +347,7 @@ exports.get = function () {
ids
=
this
.
_convertIds
(
ids
);
this
.
_exec
(
'notifications'
,
ids
,
callback
,
scope
);
this
.
_exec
(
'notifications'
,
[
3
,
ids
]
,
callback
,
scope
);
};
/**
...
...
@@ -359,7 +359,7 @@ exports.get = function () {
* @return [ Void ]
*/
exports
.
getAll
=
function
(
callback
,
scope
)
{
this
.
_exec
(
'notifications'
,
null
,
callback
,
scope
);
this
.
_exec
(
'notifications'
,
0
,
callback
,
scope
);
};
/**
...
...
@@ -369,7 +369,7 @@ exports.getAll = function (callback, scope) {
* @param [ Object ] scope The callback function's scope.
*/
exports
.
getScheduled
=
function
(
callback
,
scope
)
{
this
.
_exec
(
'
scheduledNotifications'
,
null
,
callback
,
scope
);
this
.
_exec
(
'
notifications'
,
1
,
callback
,
scope
);
};
/**
...
...
@@ -379,7 +379,7 @@ exports.getScheduled = function (callback, scope) {
* @param [ Object ] scope The callback function's scope.
*/
exports
.
getTriggered
=
function
(
callback
,
scope
)
{
this
.
_exec
(
'
triggeredNotifications'
,
null
,
callback
,
scope
);
this
.
_exec
(
'
notifications'
,
2
,
callback
,
scope
);
};
/**
...
...
@@ -394,7 +394,7 @@ exports.getTriggered = function (callback, scope) {
*/
exports
.
addActions
=
function
(
id
,
actions
,
callback
,
scope
)
{
var
config
=
{
actionGroupId
:
id
,
actions
:
actions
};
this
.
_exec
(
'actions'
,
[
1
,
config
],
callback
,
scope
);
this
.
_exec
(
'actions'
,
[
0
,
id
,
config
],
callback
,
scope
);
};
/**
...
...
@@ -407,7 +407,7 @@ exports.addActions = function (id, actions, callback, scope) {
* @return [ Void ]
*/
exports
.
removeActions
=
function
(
id
,
callback
,
scope
)
{
this
.
_exec
(
'actions'
,
[
-
1
,
id
],
callback
,
scope
);
this
.
_exec
(
'actions'
,
[
1
,
id
],
callback
,
scope
);
};
/**
...
...
@@ -420,7 +420,7 @@ exports.removeActions = function (id, callback, scope) {
* @return [ Void ]
*/
exports
.
hasActions
=
function
(
id
,
callback
,
scope
)
{
this
.
_exec
(
'actions'
,
[
0
,
id
],
callback
,
scope
);
this
.
_exec
(
'actions'
,
[
2
,
id
],
callback
,
scope
);
};
/**
...
...
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