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
3afc1f04
Commit
3afc1f04
authored
Mar 15, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Click event on iOS wasn't fired if app was not running (solves #87).
parent
5a098fb4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
22 deletions
+49
-22
README.md
README.md
+1
-0
APPLocalNotification.h
src/ios/APPLocalNotification.h
+2
-0
APPLocalNotification.m
src/ios/APPLocalNotification.m
+42
-22
local-notification.js
www/local-notification.js
+4
-0
No files found.
README.md
View file @
3afc1f04
...
...
@@ -64,6 +64,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/413).
-
[
feature:
]
New interface
`getScheduledIds`
to retrieve a list with all currently pending notifications.
-
[
enhancement:
]
Support for bigview style notifications for Android devices.
-
[
bugfix:
]
Sound didnt play properly on iOS/Android.
-
[
bugfix:
]
click event on iOS wasn't fired if app was not running.
#### Version 0.7.2 (09.02.2014)
-
[
enhancement:
]
Avoid blocking the main thread (on Android)
**(dpogue)**
.
...
...
src/ios/APPLocalNotification.h
View file @
3afc1f04
...
...
@@ -24,6 +24,8 @@
@interface
APPLocalNotification
:
CDVPlugin
// Executes all queued events
-
(
void
)
deviceready
:(
CDVInvokedUrlCommand
*
)
command
;
// Schedules a new local notification
-
(
void
)
add
:(
CDVInvokedUrlCommand
*
)
command
;
// Cancels a given local notification
...
...
src/ios/APPLocalNotification.m
View file @
3afc1f04
...
...
@@ -54,8 +54,33 @@
@end
@interface
APPLocalNotification
()
// All events will be queued until deviceready has been fired
@property
(
readwrite
,
assign
)
BOOL
deviceready
;
// Event queue
@property
(
readonly
,
nonatomic
,
retain
)
NSMutableArray
*
eventQueue
;
@end
@implementation
APPLocalNotification
@synthesize
deviceready
,
eventQueue
;
/**
* Executes all queued events.
*/
-
(
void
)
deviceready
:(
CDVInvokedUrlCommand
*
)
command
{
deviceready
=
YES
;
for
(
NSString
*
js
in
eventQueue
)
{
[
self
.
commandDelegate
evalJs
:
js
];
}
[
eventQueue
removeAllObjects
];
}
/**
* Schedules a new local notification.
*
...
...
@@ -109,8 +134,7 @@
NSArray
*
notifications
=
[[
UIApplication
sharedApplication
]
scheduledLocalNotifications
];
for
(
UILocalNotification
*
notification
in
notifications
)
{
for
(
UILocalNotification
*
notification
in
notifications
)
{
[
self
cancelNotification
:
notification
fireEvent
:
YES
];
}
...
...
@@ -214,8 +238,7 @@
[[
UIApplication
sharedApplication
]
cancelLocalNotification
:
notification
];
if
(
fireEvent
)
{
if
(
fireEvent
)
{
[
self
fireEvent
:
@"cancel"
id
:
id
json
:
json
];
}
}
...
...
@@ -339,13 +362,10 @@
if
(
!
[
self
stringIsNullOrEmpty
:
msg
])
{
if
(
!
[
self
stringIsNullOrEmpty
:
title
])
{
if
(
!
[
self
stringIsNullOrEmpty
:
title
])
{
notification
.
alertBody
=
[
NSString
stringWithFormat
:
@"%@
\n
%@"
,
title
,
msg
];
}
else
{
}
else
{
notification
.
alertBody
=
msg
;
}
}
...
...
@@ -354,9 +374,7 @@
{
if
([
sound
isEqualToString
:
@""
])
{
notification
.
soundName
=
UILocalNotificationDefaultSoundName
;
}
else
{
}
else
{
notification
.
soundName
=
sound
;
}
}
...
...
@@ -382,8 +400,7 @@
NSTimeInterval
fireDateDistance
=
[
now
timeIntervalSinceDate
:
fireDate
];
NSString
*
event
=
(
fireDateDistance
<
1
)
?
@"trigger"
:
@"click"
;
if
(
autoCancel
&&
[
event
isEqualToString
:
@"click"
])
{
if
(
autoCancel
&&
[
event
isEqualToString
:
@"click"
])
{
[
self
cancelNotification
:
notification
fireEvent
:
YES
];
}
...
...
@@ -400,8 +417,7 @@
UILocalNotification
*
localNotification
=
[
launchOptions
objectForKey
:
UIApplicationLaunchOptionsLocalNotificationKey
];
if
(
localNotification
)
{
if
(
localNotification
)
{
[
self
didReceiveLocalNotification
:
[
NSNotification
notificationWithName
:
CDVLocalNotification
object
:
localNotification
]];
...
...
@@ -418,6 +434,8 @@
NSNotificationCenter
*
notificationCenter
=
[
NSNotificationCenter
defaultCenter
];
eventQueue
=
[[
NSMutableArray
alloc
]
init
];
[
notificationCenter
addObserver
:
self
selector
:
@selector
(
didReceiveLocalNotification
:
)
name
:
CDVLocalNotification
...
...
@@ -425,7 +443,7 @@
[
notificationCenter
addObserver
:
self
selector
:
@selector
(
didFinishLaunchingWithOptions
:
)
name
:
CDVLocal
Notification
name
:
UIApplicationDidFinishLaunching
Notification
object
:
nil
];
}
...
...
@@ -446,13 +464,11 @@
*/
-
(
BOOL
)
stringIsNullOrEmpty
:
(
NSString
*
)
str
{
if
(
str
==
(
NSString
*
)[
NSNull
null
])
{
if
(
str
==
(
NSString
*
)[
NSNull
null
])
{
return
YES
;
}
if
([
str
isEqualToString
:
@""
])
{
if
([
str
isEqualToString
:
@""
])
{
return
YES
;
}
...
...
@@ -523,7 +539,11 @@
@"setTimeout('plugin.notification.local.on%@(%@)',0)"
,
event
,
params
];
[
self
.
commandDelegate
evalJs
:
js
];
if
(
deviceready
)
{
[
self
.
commandDelegate
evalJs
:
js
];
}
else
{
[
self
.
eventQueue
addObject
:
js
];
}
}
@end
www/local-notification.js
View file @
3afc1f04
...
...
@@ -212,4 +212,8 @@ channel.onCordovaReady.subscribe( function () {
plugin
.
applyPlatformSpecificOptions
();
});
channel
.
deviceready
.
subscribe
(
function
()
{
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'deviceready'
,
[]);
});
module
.
exports
=
plugin
;
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