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
cbf00120
Commit
cbf00120
authored
Apr 13, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Callbacks for `cancel` & `cancelAll`
parent
5c10b767
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
30 deletions
+59
-30
CHANGELOG.md
CHANGELOG.md
+2
-1
README.md
README.md
+8
-3
LocalNotification.java
src/android/LocalNotification.java
+13
-21
APPLocalNotification.m
src/ios/APPLocalNotification.m
+18
-0
LocalNotification.cs
src/wp8/LocalNotification.cs
+1
-0
local-notification.js
www/local-notification.js
+17
-5
No files found.
CHANGELOG.md
View file @
cbf00120
## ChangeLog
#### Version 0.8.0 (not yet released)
-
[
enhancement:
]
android 2.1 support added
(Thanks to
**khizarsonu**
)
-
[
enhancement:
]
Android 2.x (SDK >= 7) support
(Thanks to
**khizarsonu**
)
-
[
enhancement:
]
Scope parameter for
`isScheduled`
and
`getScheduledIds`
-
[
enhancement:
]
Callbacks for
`cancel`
&
`cancelAll`
#### Version 0.7.4 (22.03.2014)
-
[
bugfix:
]
Platform specific properties were ignored.
...
...
README.md
View file @
cbf00120
...
...
@@ -70,8 +70,9 @@ More informations can be found [here][PGB_plugin].
## ChangeLog
#### Version 0.8.0 (not yet released)
-
[
enhancement:
]
android 2.1 support added
(Thanks to
**khizarsonu**
)
-
[
enhancement:
]
Android 2.x (SDK >= 7) support
(Thanks to
**khizarsonu**
)
-
[
enhancement:
]
Scope parameter for
`isScheduled`
and
`getScheduledIds`
-
[
enhancement:
]
Callbacks for
`cancel`
&
`cancelAll`
#### Further informations
-
See
[
CHANGELOG.md
][
changelog
]
to get the full changelog for the plugin.
...
...
@@ -131,7 +132,9 @@ Note that only local notifications with an ID can be canceled.
-
See
[
getScheduledIds
][
getscheduledids
]
of how to retrieve a list of IDs of all scheduled local notifications.
```
javascript
window
.
plugin
.
notification
.
local
.
cancel
(
ID
);
window
.
plugin
.
notification
.
local
.
cancel
(
ID
,
function
()
{
// The notification has been canceled
},
scope
);
```
### Cancel all scheduled local notifications
...
...
@@ -142,7 +145,9 @@ The method cancels all local notifications even if they have no ID.
-
See the
[
oncancel
][
oncancel
]
event of how a listener can be registered to be notified when a local notification has been canceled.
```
javascript
window
.
plugin
.
notification
.
local
.
cancelAll
();
window
.
plugin
.
notification
.
local
.
cancelAll
(
function
()
{
// All notifications have been canceled
},
scope
);
```
### Check wether a notification with an ID is scheduled
...
...
src/android/LocalNotification.java
View file @
cbf00120
...
...
@@ -67,7 +67,7 @@ public class LocalNotification extends CordovaPlugin {
}
@Override
public
boolean
execute
(
String
action
,
final
JSONArray
args
,
CallbackContext
callbackContext
)
throws
JSONException
{
public
boolean
execute
(
String
action
,
final
JSONArray
args
,
final
CallbackContext
command
)
throws
JSONException
{
if
(
action
.
equalsIgnoreCase
(
"add"
))
{
cordova
.
getThreadPool
().
execute
(
new
Runnable
()
{
public
void
run
()
{
...
...
@@ -78,8 +78,6 @@ public class LocalNotification extends CordovaPlugin {
add
(
options
,
true
);
}
});
return
true
;
}
if
(
action
.
equalsIgnoreCase
(
"cancel"
))
{
...
...
@@ -89,10 +87,9 @@ public class LocalNotification extends CordovaPlugin {
cancel
(
id
);
unpersist
(
id
);
execCallback
(
command
);
}
});
return
true
;
}
if
(
action
.
equalsIgnoreCase
(
"cancelAll"
))
{
...
...
@@ -100,24 +97,19 @@ public class LocalNotification extends CordovaPlugin {
public
void
run
()
{
cancelAll
();
unpersistAll
();
execCallback
(
command
);
}
});
return
true
;
}
if
(
action
.
equalsIgnoreCase
(
"isScheduled"
))
{
String
id
=
args
.
optString
(
0
);
isScheduled
(
id
,
callbackContext
);
return
true
;
isScheduled
(
id
,
command
);
}
if
(
action
.
equalsIgnoreCase
(
"getScheduledIds"
))
{
getScheduledIds
(
callbackContext
);
return
true
;
getScheduledIds
(
command
);
}
if
(
action
.
equalsIgnoreCase
(
"deviceready"
))
{
...
...
@@ -126,24 +118,17 @@ public class LocalNotification extends CordovaPlugin {
deviceready
();
}
});
return
true
;
}
if
(
action
.
equalsIgnoreCase
(
"pause"
))
{
isInBackground
=
true
;
return
true
;
}
if
(
action
.
equalsIgnoreCase
(
"resume"
))
{
isInBackground
=
false
;
return
true
;
}
// Returning false results in a "MethodNotFound" error.
return
false
;
return
true
;
}
/**
...
...
@@ -310,6 +295,13 @@ public class LocalNotification extends CordovaPlugin {
}
/**
* Simply invokes the callback without any parameter.
*/
private
static
void
execCallback
(
CallbackContext
command
)
{
command
.
sendPluginResult
(
new
PluginResult
(
PluginResult
.
Status
.
OK
));
}
/**
* Fires the given event.
*
* @param {String} event The Name of the event
...
...
src/ios/APPLocalNotification.m
View file @
cbf00120
...
...
@@ -53,6 +53,8 @@
-
(
NSString
*
)
applicationState
;
// Retrieves all scheduled notifications
-
(
NSArray
*
)
scheduledNotifications
;
// Simply invokes the callback without any parameter
-
(
void
)
execCallback
:(
CDVInvokedUrlCommand
*
)
command
;
// Fires the given event
-
(
void
)
fireEvent
:(
NSString
*
)
event
id
:(
NSString
*
)
id
json
:(
NSString
*
)
json
;
...
...
@@ -133,6 +135,8 @@
if
(
notification
)
{
[
self
cancelNotification
:
notification
fireEvent
:
YES
];
}
[
self
execCallback
:
command
];
}];
}
...
...
@@ -153,6 +157,8 @@
[[
UIApplication
sharedApplication
]
setApplicationIconBadgeNumber
:
0
];
[
self
execCallback
:
command
];
}];
}
...
...
@@ -561,6 +567,18 @@
}
/**
* Simply invokes the callback without any parameter.
*/
-
(
void
)
execCallback
:
(
CDVInvokedUrlCommand
*
)
command
{
CDVPluginResult
*
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}
/**
* Fires the given event.
*
* @param {NSString} event
...
...
src/wp8/LocalNotification.cs
View file @
cbf00120
...
...
@@ -84,6 +84,7 @@ namespace Cordova.Extension.Commands
cancelAll
(
jsonArgs
);
FireEvent
(
"cancel"
,
notificationID
,
""
);
DispatchCommandResult
();
}
/// <summary>
...
...
www/local-notification.js
View file @
cbf00120
...
...
@@ -167,18 +167,30 @@ LocalNotification.prototype = {
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* A function to be called after the notification has been canceled
* @param {Object} scope
* The scope for the callback function
*/
cancel
:
function
(
id
)
{
var
id
=
id
.
toString
();
cancel
:
function
(
id
,
callback
,
scope
)
{
var
id
=
id
.
toString
(),
callbackFn
=
this
.
createCallbackFn
(
callback
,
scope
);
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'cancel'
,
[
id
]);
cordova
.
exec
(
callbackFn
,
null
,
'LocalNotification'
,
'cancel'
,
[
id
]);
},
/**
* Removes all previously registered notifications.
*
* @param {Function} callback
* A function to be called after all notifications have been canceled
* @param {Object} scope
* The scope for the callback function
*/
cancelAll
:
function
()
{
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'cancelAll'
,
[]);
cancelAll
:
function
(
callback
,
scope
)
{
var
callbackFn
=
this
.
createCallbackFn
(
callback
,
scope
);
cordova
.
exec
(
callbackFn
,
null
,
'LocalNotification'
,
'cancelAll'
,
[]);
},
/**
...
...
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