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
30da4b36
Commit
30da4b36
authored
Sep 23, 2016
by
Sebastián Katzer
Committed by
GitHub
Sep 23, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1093 from spk0611/master
iOS 10 (some hot fixes)
parents
366557fd
9ad32cf2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
3 deletions
+57
-3
LocalNotification.java
src/android/LocalNotification.java
+12
-3
APPLocalNotification.m
src/ios/APPLocalNotification.m
+45
-0
No files found.
src/android/LocalNotification.java
View file @
30da4b36
...
@@ -37,6 +37,7 @@ import org.json.JSONObject;
...
@@ -37,6 +37,7 @@ import org.json.JSONObject;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.lang.Exception
;
import
de.appplant.cordova.plugin.notification.Manager
;
import
de.appplant.cordova.plugin.notification.Manager
;
import
de.appplant.cordova.plugin.notification.Notification
;
import
de.appplant.cordova.plugin.notification.Notification
;
...
@@ -213,10 +214,18 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -213,10 +214,18 @@ public class LocalNotification extends CordovaPlugin {
for
(
int
i
=
0
;
i
<
notifications
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
notifications
.
length
();
i
++)
{
JSONObject
options
=
notifications
.
optJSONObject
(
i
);
JSONObject
options
=
notifications
.
optJSONObject
(
i
);
Notification
notification
=
try
{
getNotificationMgr
().
schedule
(
options
,
TriggerReceiver
.
class
);
Notification
notification
=
getNotificationMgr
().
schedule
(
options
,
TriggerReceiver
.
class
);
fireEvent
(
"schedule"
,
notification
);
fireEvent
(
"schedule"
,
notification
);
}
catch
(
Exception
generic
)
{
//silently ignore the exception
//on some samsung devices there is a known bug where a 500 alarms limit can crash the app
//http://developer.samsung.com/forum/board/thread/view.do?boardName=General&messageId=280286&listLines=15&startId=zzzzz%7E&searchSubId=0000000001
}
}
}
}
}
...
...
src/ios/APPLocalNotification.m
View file @
30da4b36
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
#import "UIApplication+APPLocalNotification.h"
#import "UIApplication+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h"
#import "UILocalNotification+APPLocalNotification.h"
@import
UserNotifications
;
@interface
APPLocalNotification
()
@interface
APPLocalNotification
()
// Retrieves the application state
// Retrieves the application state
...
@@ -76,6 +78,8 @@
...
@@ -76,6 +78,8 @@
notification
=
[[
UILocalNotification
alloc
]
notification
=
[[
UILocalNotification
alloc
]
initWithOptions
:
options
];
initWithOptions
:
options
];
notification
.
timeZone
=
[
NSTimeZone
defaultTimeZone
];
notification
.
repeatInterval
=
0
;
[
self
scheduleLocalNotification
:[
notification
copy
]];
[
self
scheduleLocalNotification
:[
notification
copy
]];
[
self
fireEvent
:
@"schedule"
notification
:
notification
];
[
self
fireEvent
:
@"schedule"
notification
:
notification
];
...
@@ -691,6 +695,47 @@
...
@@ -691,6 +695,47 @@
*/
*/
-
(
void
)
fireEvent
:
(
NSString
*
)
event
notification
:
(
UILocalNotification
*
)
notification
-
(
void
)
fireEvent
:
(
NSString
*
)
event
notification
:
(
UILocalNotification
*
)
notification
{
{
if
(
IsAtLeastiOSVersion
(
@"10.0"
))
{
UNMutableNotificationContent
*
content
=
[[
UNMutableNotificationContent
alloc
]
init
];
content
.
title
=
[
NSString
localizedUserNotificationStringForKey
:
notification
.
alertTitle
arguments
:
nil
];
content
.
body
=
[
NSString
localizedUserNotificationStringForKey
:
notification
.
alertBody
arguments
:
nil
];
content
.
sound
=
[
UNNotificationSound
defaultSound
];
NSDate
*
fireDate
=
notification
.
fireDate
;
if
(
fireDate
==
nil
)
{
fireDate
=
[
NSDate
date
];
}
NSCalendar
*
gregorianCalendar
=
[[
NSCalendar
alloc
]
initWithCalendarIdentifier
:
NSGregorianCalendar
];
// Extract all date components into dateComponents
NSDateComponents
*
dateComponents
=
[
gregorianCalendar
components
:
NSYearCalendarUnit
|
NSMonthCalendarUnit
|
NSDayCalendarUnit
|
NSHourCalendarUnit
|
NSMinuteCalendarUnit
|
NSSecondCalendarUnit
fromDate
:
fireDate
];
[
dateComponents
setTimeZone
:[
NSTimeZone
defaultTimeZone
]];
/// 4. update application icon badge number
//content.badge = @([[UIApplication sharedApplication] applicationIconBadgeNumber] + 1);
// Deliver the notification at the fire date.
UNCalendarNotificationTrigger
*
trigger
=
[
UNCalendarNotificationTrigger
triggerWithDateMatchingComponents
:
dateComponents
repeats
:
NO
];
NSString
*
identifier
=
@"DefaultNotificationIdentifier"
;
if
(
notification
.
userInfo
!=
nil
&&
[
notification
.
userInfo
objectForKey
:
@"id"
]
!=
nil
)
{
identifier
=
[
notification
.
userInfo
objectForKey
:
@"id"
];
}
UNNotificationRequest
*
request
=
[
UNNotificationRequest
requestWithIdentifier
:
identifier
content
:
content
trigger
:
trigger
];
/// 3. schedule localNotification
UNUserNotificationCenter
*
center
=
[
UNUserNotificationCenter
currentNotificationCenter
];
[
center
addNotificationRequest
:
request
withCompletionHandler
:
^
(
NSError
*
_Nullable
error
)
{
if
(
!
error
)
{
NSLog
(
@"add NotificationRequest succeeded!"
);
}
}];
}
NSString
*
js
;
NSString
*
js
;
NSString
*
params
=
[
NSString
stringWithFormat
:
NSString
*
params
=
[
NSString
stringWithFormat
:
@"
\"
%@
\"
"
,
self
.
applicationState
];
@"
\"
%@
\"
"
,
self
.
applicationState
];
...
...
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