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
049680a9
Commit
049680a9
authored
Mar 24, 2015
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Register trigger handler for each scheduled notification on launch
parent
54e8202b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
20 deletions
+44
-20
LocalNotificationCore.js
src/windows/LocalNotificationCore.js
+6
-8
LocalNotificationUtil.js
src/windows/LocalNotificationUtil.js
+38
-12
No files found.
src/windows/LocalNotificationCore.js
View file @
049680a9
...
@@ -32,14 +32,12 @@ exports.core = {
...
@@ -32,14 +32,12 @@ exports.core = {
*/
*/
deviceready
:
function
()
{
deviceready
:
function
()
{
var
plugin
=
cordova
.
plugins
.
notification
.
local
,
var
plugin
=
cordova
.
plugins
.
notification
.
local
,
args
;
events
=
this
.
eventQueue
;
this
.
isReady
=
true
;
this
.
isReady
=
true
;
for
(
var
i
=
0
;
i
<
this
.
eventQueue
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
events
.
length
;
i
++
)
{
args
=
this
.
eventQueue
[
i
];
plugin
.
fireEvent
.
apply
(
plugin
,
events
[
i
]);
plugin
.
fireEvent
.
apply
(
plugin
,
args
);
}
}
this
.
eventQueue
=
[];
this
.
eventQueue
=
[];
...
@@ -370,7 +368,7 @@ exports.core = {
...
@@ -370,7 +368,7 @@ exports.core = {
var
toasts
=
this
.
getScheduledToasts
(),
var
toasts
=
this
.
getScheduledToasts
(),
notifications
=
[];
notifications
=
[];
if
(
ids
.
length
===
0
)
{
if
(
!
ids
||
ids
.
length
===
0
)
{
ids
=
this
.
getAllIds
();
ids
=
this
.
getAllIds
();
}
}
...
@@ -397,7 +395,7 @@ exports.core = {
...
@@ -397,7 +395,7 @@ exports.core = {
* List of local notification IDs
* List of local notification IDs
*/
*/
getScheduled
:
function
(
ids
)
{
getScheduled
:
function
(
ids
)
{
if
(
ids
.
length
===
0
)
{
if
(
!
ids
||
ids
.
length
===
0
)
{
ids
=
this
.
getAllIds
();
ids
=
this
.
getAllIds
();
}
}
...
@@ -412,7 +410,7 @@ exports.core = {
...
@@ -412,7 +410,7 @@ exports.core = {
* List of local notification IDs
* List of local notification IDs
*/
*/
getTriggered
:
function
(
ids
)
{
getTriggered
:
function
(
ids
)
{
if
(
ids
.
length
===
0
)
{
if
(
!
ids
||
ids
.
length
===
0
)
{
ids
=
this
.
getAllIds
();
ids
=
this
.
getAllIds
();
}
}
...
...
src/windows/LocalNotificationUtil.js
View file @
049680a9
...
@@ -19,6 +19,9 @@
...
@@ -19,6 +19,9 @@
under the License.
under the License.
*/
*/
var
channel
=
require
(
'cordova/channel'
);
exports
=
require
(
'de.appplant.cordova.plugin.local-notification.LocalNotification.Proxy.Core'
).
core
;
exports
=
require
(
'de.appplant.cordova.plugin.local-notification.LocalNotification.Proxy.Core'
).
core
;
...
@@ -289,6 +292,20 @@ exports.callOnTrigger = function (notification, callback) {
...
@@ -289,6 +292,20 @@ exports.callOnTrigger = function (notification, callback) {
};
};
/**
/**
* Sets trigger event for all scheduled local notification.
*
* @param {Function} callback
* Callback function
*/
exports
.
callOnTriggerForScheduled
=
function
(
callback
)
{
var
notifications
=
this
.
getScheduled
();
for
(
var
i
=
0
;
i
<
notifications
.
length
;
i
++
)
{
this
.
callOnTrigger
(
notifications
[
i
],
callback
);
}
};
/**
* The application state - background or foreground.
* The application state - background or foreground.
*
*
* @return String
* @return String
...
@@ -328,6 +345,27 @@ exports.fireEvent = function (event, notification) {
...
@@ -328,6 +345,27 @@ exports.fireEvent = function (event, notification) {
* LIFE CYCLE *
* LIFE CYCLE *
**************/
**************/
// Called before 'deviceready' event
channel
.
onCordovaReady
.
subscribe
(
function
()
{
// Register trigger handler for each scheduled notification
exports
.
callOnTriggerForScheduled
(
function
(
notification
)
{
this
.
updateBadge
(
notification
.
badge
);
this
.
fireEvent
(
'trigger'
,
notification
);
});
});
// Handle onclick event
WinJS
.
Application
.
addEventListener
(
'activated'
,
function
(
args
)
{
var
id
=
args
.
detail
.
arguments
,
notification
=
exports
.
getAll
([
id
])[
0
];
if
(
!
notification
)
return
;
exports
.
clearLocalNotification
(
id
);
exports
.
fireEvent
(
'click'
,
notification
);
},
false
);
// App is running in background
// App is running in background
document
.
addEventListener
(
'pause'
,
function
()
{
document
.
addEventListener
(
'pause'
,
function
()
{
exports
.
isInBackground
=
true
;
exports
.
isInBackground
=
true
;
...
@@ -342,15 +380,3 @@ document.addEventListener('resume', function () {
...
@@ -342,15 +380,3 @@ document.addEventListener('resume', function () {
document
.
addEventListener
(
'deviceready'
,
function
()
{
document
.
addEventListener
(
'deviceready'
,
function
()
{
exports
.
isInBackground
=
false
;
exports
.
isInBackground
=
false
;
},
false
);
},
false
);
// Handle onclick event
WinJS
.
Application
.
addEventListener
(
'activated'
,
function
(
args
)
{
var
id
=
args
.
detail
.
arguments
,
notification
=
exports
.
getAll
([
id
])[
0
];
if
(
!
notification
)
return
;
exports
.
clearLocalNotification
(
id
);
exports
.
fireEvent
(
'click'
,
notification
);
},
false
);
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