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
afd6a480
Commit
afd6a480
authored
Apr 13, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small coding changes
parent
d28f1aaf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
23 deletions
+61
-23
local-notification.js
www/local-notification.js
+61
-23
No files found.
www/local-notification.js
View file @
afd6a480
...
...
@@ -58,10 +58,14 @@ LocalNotification.prototype = {
/**
* @private
* Merge settings with default values
*
* Merges custom properties with the default values.
*
* @param {Object} options
* Set of custom values
*
* @retrun {Object}
* The merged property list
*/
mergeWithDefaults
:
function
(
options
)
{
var
defaults
=
this
.
getDefaults
();
...
...
@@ -77,6 +81,11 @@ LocalNotification.prototype = {
/**
* @private
*
* Merges the platform specific properties into the default properties.
*
* @return {Object}
* The default properties for the platform
*/
applyPlatformSpecificOptions
:
function
()
{
var
defaults
=
this
.
_defaults
;
...
...
@@ -94,13 +103,18 @@ LocalNotification.prototype = {
defaults
.
image
=
null
;
defaults
.
wideImage
=
null
;
};
return
defaults
;
},
/**
* Add a new entry to the registry
*
* @param {Object} options
* @return {Number} The notification's ID
* The notification properties
*
* @return {Number}
* The notification's ID
*/
add
:
function
(
options
)
{
var
options
=
this
.
mergeWithDefaults
(
options
),
...
...
@@ -130,77 +144,93 @@ LocalNotification.prototype = {
},
/**
* Cancels the specified notification
* Cancels the specified notification
.
*
* @param {String} id of the notification
* @param {String} id
* The ID of the notification
*/
cancel
:
function
(
id
)
{
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'cancel'
,
[
id
.
toString
()]);
var
id
=
id
.
toString
();
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'cancel'
,
[
id
]);
},
/**
* Removes all previously registered notifications
* Removes all previously registered notifications
.
*/
cancelAll
:
function
()
{
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'cancelAll'
,
[]);
},
/**
* @async
*
* Retrieves a list with all currently pending notifications.
*
* @param {Function} callback
* A callback function to be called with the list
*/
getScheduledIds
:
function
(
callback
)
{
cordova
.
exec
(
callback
,
null
,
'LocalNotification'
,
'getScheduledIds'
,
[]);
},
/**
* @async
*
* Checks wether a notification with an ID is scheduled.
*
* @param {String} id
* The ID of the notification
* @param {Function} callback
* A callback function to be called with the list
*/
isScheduled
:
function
(
id
,
callback
)
{
cordova
.
exec
(
callback
,
null
,
'LocalNotification'
,
'isScheduled'
,
[
id
.
toString
()]);
var
id
=
id
.
toString
();
cordova
.
exec
(
callback
,
null
,
'LocalNotification'
,
'isScheduled'
,
[
id
]);
},
/**
* Occurs when a notification was added.
*
* @param {String} id The ID of the notification
* @param {String} state Either "foreground" or "background"
* @param {String} json A custom (JSON) string
* @param {String} id
* The ID of the notification
* @param {String} state
* Either "foreground" or "background"
* @param {String} json
* A custom (JSON) string
*/
onadd
:
function
(
id
,
state
,
json
)
{},
/**
* Occurs when the notification is triggered.
*
* @param {String} id The ID of the notification
* @param {String} state Either "foreground" or "background"
* @param {String} json A custom (JSON) string
* @param {String} id
* The ID of the notification
* @param {String} state
* Either "foreground" or "background"
* @param {String} json
* A custom (JSON) string
*/
ontrigger
:
function
(
id
,
state
,
json
)
{},
/**
* Fires after the notification was clicked.
*
* @param {String} id The ID of the notification
* @param {String} state Either "foreground" or "background"
* @param {String} json A custom (JSON) string
* @param {String} id
* The ID of the notification
* @param {String} state
* Either "foreground" or "background"
* @param {String} json
* A custom (JSON) string
*/
onclick
:
function
(
id
,
state
,
json
)
{},
/**
* Fires if the notification was canceled.
*
* @param {String} id The ID of the notification
* @param {String} state Either "foreground" or "background"
* @param {String} json A custom (JSON) string
* @param {String} id
* The ID of the notification
* @param {String} state
* Either "foreground" or "background"
* @param {String} json
* A custom (JSON) string
*/
oncancel
:
function
(
id
,
state
,
json
)
{}
};
...
...
@@ -208,24 +238,32 @@ LocalNotification.prototype = {
var
plugin
=
new
LocalNotification
(),
channel
=
require
(
'cordova/channel'
);
// Called after all 'deviceready' listener are called
channel
.
deviceready
.
subscribe
(
function
()
{
// Device is ready now, the listeners are registered and all queued events
// can be executed now.
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'deviceready'
,
[]);
});
channel
.
onCordovaReady
.
subscribe
(
function
()
{
// The cordova device plugin is ready now
channel
.
onCordovaInfoReady
.
subscribe
(
function
()
{
if
(
device
.
platform
==
'Android'
)
{
channel
.
onPause
.
subscribe
(
function
()
{
// Necessary to set the state to `background`
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'pause'
,
[]);
});
channel
.
onResume
.
subscribe
(
function
()
{
// Necessary to set the state to `foreground`
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'resume'
,
[]);
});
// Necessary to set the state to `foreground`
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'resume'
,
[]);
}
// Merges the platform specific properties into the default properties
plugin
.
applyPlatformSpecificOptions
();
});
});
...
...
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