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
89be6b9d
Commit
89be6b9d
authored
Mar 20, 2015
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle click event on windows platform
parent
1a6ebf04
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
48 deletions
+84
-48
LocalNotificationCore.js
src/windows/LocalNotificationCore.js
+57
-42
LocalNotificationProxy.js
src/windows/LocalNotificationProxy.js
+1
-1
LocalNotificationUtil.js
src/windows/LocalNotificationUtil.js
+26
-5
No files found.
src/windows/LocalNotificationCore.js
View file @
89be6b9d
...
...
@@ -27,8 +27,23 @@ var Notifications = Windows.UI.Notifications,
exports
.
core
=
{
// Array of unactivated notifications
unactivatedIds
:
[],
/**
* Executes all queued events.
*/
deviceready
:
function
()
{
var
plugin
=
cordova
.
plugins
.
notification
.
local
,
args
;
this
.
isReady
=
true
;
for
(
var
i
=
0
;
i
<
this
.
eventQueue
.
length
;
i
++
)
{
args
=
this
.
eventQueue
[
i
];
plugin
.
fireEvent
.
apply
(
plugin
,
args
);
}
this
.
eventQueue
=
[];
},
/**
* Schedules new local notifications.
...
...
@@ -125,42 +140,6 @@ exports.core = {
},
/**
* Cancels the local notification with the given ID.
*
* @param {String} id
* Local notification ID
*/
cancelLocalNotification
:
function
(
id
)
{
var
notifier
=
this
.
getToastNotifier
(),
history
=
this
.
getToastHistory
(),
toasts
=
this
.
getScheduledToast
();
history
.
remove
(
'Toast'
+
id
);
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
var
toast
=
toasts
[
i
];
if
(
toast
.
id
==
id
||
toast
.
id
==
id
+
'-2'
)
{
notifier
.
removeFromSchedule
(
toast
);
}
}
},
/**
* Clears the local notification with the given ID.
*
* @param {String} id
* Local notification ID
*/
clearLocalNotification
:
function
(
id
)
{
this
.
getToastHistory
().
remove
(
'Toast'
+
id
);
if
(
this
.
isTriggered
(
id
)
&&
!
this
.
isScheduled
(
id
))
{
this
.
cancelLocalNotification
(
id
);
}
},
/**
* Updates existing notifications specified by IDs in options.
*
* @param {Object[]} notifications
...
...
@@ -192,6 +171,20 @@ exports.core = {
},
/**
* Clears the local notification with the given ID.
*
* @param {String} id
* Local notification ID
*/
clearLocalNotification
:
function
(
id
)
{
this
.
getToastHistory
().
remove
(
'Toast'
+
id
);
if
(
this
.
isTriggered
(
id
)
&&
!
this
.
isScheduled
(
id
))
{
this
.
cancelLocalNotification
(
id
);
}
},
/**
* Clears all notifications.
*/
clearAll
:
function
()
{
...
...
@@ -221,6 +214,28 @@ exports.core = {
},
/**
* Cancels the local notification with the given ID.
*
* @param {String} id
* Local notification ID
*/
cancelLocalNotification
:
function
(
id
)
{
var
notifier
=
this
.
getToastNotifier
(),
history
=
this
.
getToastHistory
(),
toasts
=
this
.
getScheduledToasts
();
history
.
remove
(
'Toast'
+
id
);
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
var
toast
=
toasts
[
i
];
if
(
toast
.
id
==
id
||
toast
.
id
==
id
+
'-2'
)
{
notifier
.
removeFromSchedule
(
toast
);
}
}
},
/**
* Cancels all notifications.
*/
cancelAll
:
function
()
{
...
...
@@ -268,7 +283,7 @@ exports.core = {
* Lists all local notification IDs.
*/
getAllIds
:
function
()
{
var
toasts
=
this
.
getScheduledToast
(),
var
toasts
=
this
.
getScheduledToast
s
(),
ids
=
[];
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
...
...
@@ -284,7 +299,7 @@ exports.core = {
* Lists all scheduled notification IDs.
*/
getScheduledIds
:
function
()
{
var
toasts
=
this
.
getScheduledToast
(),
var
toasts
=
this
.
getScheduledToast
s
(),
ids
=
[];
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
...
...
@@ -303,7 +318,7 @@ exports.core = {
* Lists all scheduled notification IDs.
*/
getTriggeredIds
:
function
()
{
var
toasts
=
this
.
getScheduledToast
(),
var
toasts
=
this
.
getScheduledToast
s
(),
ids
=
[];
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
...
...
@@ -328,7 +343,7 @@ exports.core = {
* Local notification life cycle type
*/
getAll
:
function
(
ids
,
type
)
{
var
toasts
=
this
.
getScheduledToast
(),
var
toasts
=
this
.
getScheduledToast
s
(),
notifications
=
[];
if
(
ids
.
length
===
0
)
{
...
...
src/windows/LocalNotificationProxy.js
View file @
89be6b9d
...
...
@@ -23,7 +23,7 @@
* Executes all queued events.
*/
exports
.
deviceready
=
function
()
{
exports
.
core
.
deviceready
();
};
/**
...
...
src/windows/LocalNotificationUtil.js
View file @
89be6b9d
...
...
@@ -29,6 +29,11 @@ exports = require('de.appplant.cordova.plugin.local-notification.LocalNotificati
// True if App is running, false if suspended
exports
.
isInBackground
=
true
;
// Indicates if the device is ready (to receive events)
exports
.
isReady
=
false
;
// Queues all events before deviceready
exports
.
eventQueue
=
[];
/********
* UTIL *
...
...
@@ -158,7 +163,7 @@ exports.getToastNotifier = function () {
*
* @return Array
*/
exports
.
getScheduledToast
=
function
()
{
exports
.
getScheduledToast
s
=
function
()
{
return
this
.
getToastNotifier
().
getScheduledToastNotifications
();
};
...
...
@@ -229,7 +234,7 @@ exports.isToastTriggered = function (toast) {
* @param Object
*/
exports
.
findToastById
=
function
(
id
)
{
var
toasts
=
this
.
getScheduledToast
Notification
s
();
var
toasts
=
this
.
getScheduledToasts
();
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
var
toast
=
toasts
[
i
];
...
...
@@ -284,12 +289,19 @@ exports.getApplicationState = function () {
*/
exports
.
fireEvent
=
function
(
event
,
notification
)
{
var
plugin
=
cordova
.
plugins
.
notification
.
local
.
core
,
state
=
this
.
getApplicationState
();
state
=
this
.
getApplicationState
(),
args
;
if
(
notification
)
{
plugin
.
fireEvent
(
event
,
notification
,
state
);
args
=
[
event
,
notification
,
state
];
}
else
{
args
=
[
event
,
state
];
}
if
(
this
.
isReady
)
{
plugin
.
fireEvent
.
apply
(
plugin
,
args
);
}
else
{
plugin
.
fireEvent
(
event
,
state
);
this
.
eventQueue
.
push
(
args
);
}
};
...
...
@@ -312,3 +324,12 @@ document.addEventListener('resume', function () {
document
.
addEventListener
(
'deviceready'
,
function
()
{
exports
.
isInBackground
=
false
;
},
false
);
// Handle onclick event
WinJS
.
Application
.
addEventListener
(
'activated'
,
function
(
args
)
{
var
id
=
args
.
detail
.
arguments
,
notification
=
exports
.
getAll
([
id
])[
0
];
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