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
396829d8
Commit
396829d8
authored
Sep 06, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Queue events if device not yet ready and save launch details on windows
parent
55875628
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
17 deletions
+59
-17
APPLocalNotification.h
src/ios/APPLocalNotification.h
+2
-2
APPLocalNotification.m
src/ios/APPLocalNotification.m
+11
-12
LocalNotificationProxy.js
src/windows/LocalNotificationProxy.js
+44
-1
local-notification-util.js
www/local-notification-util.js
+2
-2
No files found.
src/ios/APPLocalNotification.h
View file @
396829d8
...
...
@@ -26,9 +26,9 @@
@interface
APPLocalNotification
:
CDVPlugin
<
UNUserNotificationCenterDelegate
>
// Set launchDetails object
-
(
void
)
launch
Details
:
(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
launch
:
(
CDVInvokedUrlCommand
*
)
command
;
// Execute all queued events
-
(
void
)
device
ready
:(
CDVInvokedUrlCommand
*
)
command
;
-
(
void
)
ready
:(
CDVInvokedUrlCommand
*
)
command
;
// Check permission to show notifications
-
(
void
)
check
:(
CDVInvokedUrlCommand
*
)
command
;
...
...
src/ios/APPLocalNotification.m
View file @
396829d8
...
...
@@ -47,13 +47,12 @@
*
* @return [ Void ]
*/
-
(
void
)
launch
Details
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
launch
:(
CDVInvokedUrlCommand
*
)
command
{
if
(
!
_launchDetails
)
return
;
NSString
*
js
;
js
=
[
NSString
stringWithFormat
:
@"cordova.plugins.notification.local.launchDetails = {id:%@, action:'%@'}"
,
_launchDetails
[
0
],
_launchDetails
[
1
]];
...
...
@@ -68,7 +67,7 @@
*
* @return [ Void ]
*/
-
(
void
)
device
ready
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
ready
:(
CDVInvokedUrlCommand
*
)
command
{
deviceready
=
YES
;
...
...
@@ -119,18 +118,18 @@
for
(
NSDictionary
*
options
in
notifications
)
{
NSNumber
*
id
=
[
options
objectForKey
:
@"id"
];
UNNotificationRequest
*
notification
;
notification
=
[
_center
getNotificationWithId
:
id
];
if
(
!
notification
)
continue
;
[
self
updateNotification
:[
notification
copy
]
withOptions
:
options
];
[
self
fireEvent
:
@"update"
notification
:
notification
];
}
[
self
execCallback
:
command
];
}];
}
...
...
@@ -240,7 +239,7 @@
default:
type
=
@"unknown"
;
}
CDVPluginResult
*
result
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsString
:
type
];
...
...
@@ -316,11 +315,11 @@
NSArray
*
notifications
;
notifications
=
[
_center
getNotificationOptionsById
:
ids
];
CDVPluginResult
*
result
;
result
=
[
CDVPluginResult
resultWithStatus
:
CDVCommandStatus_OK
messageAsDictionary
:[
notifications
firstObject
]];
[
self
.
commandDelegate
sendPluginResult
:
result
callbackId
:
command
.
callbackId
];
}];
...
...
@@ -489,7 +488,7 @@
APPNotificationContent
*
newNotification
=
[[
APPNotificationContent
alloc
]
initWithOptions
:
options
];
[
self
scheduleNotification
:
newNotification
];
}
...
...
src/windows/LocalNotificationProxy.js
View file @
396829d8
...
...
@@ -22,7 +22,41 @@
var
LocalNotification
=
LocalNotificationProxy
.
LocalNotification
,
ActivationKind
=
Windows
.
ApplicationModel
.
Activation
.
ActivationKind
;
var
impl
=
new
LocalNotificationProxy
.
LocalNotificationProxy
();
var
impl
=
new
LocalNotificationProxy
.
LocalNotificationProxy
(),
queue
=
[],
ready
=
false
;
/**
* Set launchDetails object.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
* @param [ Array ] args Interface arguments
*
* @return [ Void ]
*/
exports
.
launch
=
function
(
success
,
error
,
args
)
{
var
plugin
=
cordova
.
plugins
.
notification
.
local
;
if
(
args
.
length
===
0
||
plugin
.
launchDetails
)
return
;
plugin
.
launchDetails
=
{
id
:
args
[
0
],
action
:
args
[
1
]
};
};
/**
* To execute all queued events.
*
* @return [ Void ]
*/
exports
.
ready
=
function
()
{
ready
=
true
;
for
(
var
i
=
0
;
i
<
queue
.
length
;
i
++
)
{
exports
.
fireEvent
.
apply
(
exports
,
queue
[
i
]);
}
queue
=
[];
};
/**
* Check permission to show notifications.
...
...
@@ -301,6 +335,10 @@ exports.clicked = function (xml, input) {
meta
.
text
=
input
.
first
().
current
.
value
;
}
if
(
!
ready
)
{
exports
.
launch
(
null
,
null
,
[
toast
.
id
,
event
]);
}
exports
.
fireEvent
(
event
,
toast
,
meta
);
};
...
...
@@ -317,6 +355,11 @@ exports.fireEvent = function (event, toast, data) {
var
meta
=
Object
.
assign
({
event
:
event
},
data
),
plugin
=
cordova
.
plugins
.
notification
.
local
.
core
;
if
(
!
ready
)
{
queue
.
push
(
arguments
);
return
;
}
if
(
toast
)
{
plugin
.
fireEvent
(
event
,
exports
.
clone
(
toast
),
meta
);
}
else
{
...
...
www/local-notification-util.js
View file @
396829d8
...
...
@@ -362,13 +362,13 @@ exports.exec = function (action, args, callback, scope) {
channel
.
deviceready
.
subscribe
(
function
()
{
// Device is ready now, the listeners are registered
// and all queued events can be executed.
exports
.
exec
(
'
device
ready'
);
exports
.
exec
(
'ready'
);
});
// Called before 'deviceready' event
channel
.
onCordovaReady
.
subscribe
(
function
()
{
// Set launchDetails object
exports
.
exec
(
'launch
Details
'
);
exports
.
exec
(
'launch'
);
// Device plugin is ready now
channel
.
onCordovaInfoReady
.
subscribe
(
function
()
{
// Merge platform specifics into defaults
...
...
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