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
15d3d3e1
Commit
15d3d3e1
authored
Sep 27, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix UI main thread warnings with iOS11
parent
2e0bcaf0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
6 deletions
+32
-6
APPLocalNotification.m
src/ios/APPLocalNotification.m
+32
-6
No files found.
src/ios/APPLocalNotification.m
View file @
15d3d3e1
...
@@ -27,9 +27,9 @@
...
@@ -27,9 +27,9 @@
@interface
APPLocalNotification
()
@interface
APPLocalNotification
()
@property
(
strong
,
nonatomic
)
UIApplication
*
app
;
@property
(
strong
,
nonatomic
)
UNUserNotificationCenter
*
center
;
@property
(
strong
,
nonatomic
)
UNUserNotificationCenter
*
center
;
@property
(
readwrite
,
assign
)
BOOL
deviceready
;
@property
(
readwrite
,
assign
)
BOOL
deviceready
;
@property
(
readwrite
,
assign
)
BOOL
isActive
;
@property
(
readonly
,
nonatomic
,
retain
)
NSArray
*
launchDetails
;
@property
(
readonly
,
nonatomic
,
retain
)
NSArray
*
launchDetails
;
@property
(
readonly
,
nonatomic
,
retain
)
NSMutableArray
*
eventQueue
;
@property
(
readonly
,
nonatomic
,
retain
)
NSMutableArray
*
eventQueue
;
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
@implementation
APPLocalNotification
@implementation
APPLocalNotification
@synthesize
deviceready
,
eventQueue
;
@synthesize
deviceready
,
isActive
,
eventQueue
;
#pragma mark -
#pragma mark -
#pragma mark Interface
#pragma mark Interface
...
@@ -169,7 +169,7 @@
...
@@ -169,7 +169,7 @@
{
{
[
self
.
commandDelegate
runInBackground
:
^
{
[
self
.
commandDelegate
runInBackground
:
^
{
[
_center
clearAllNotifications
];
[
_center
clearAllNotifications
];
[
_app
setApplicationIconBadgeNumber
:
0
];
[
self
clearApplicationIconBadgeNumber
];
[
self
fireEvent
:
@"clearall"
];
[
self
fireEvent
:
@"clearall"
];
[
self
execCallback
:
command
];
[
self
execCallback
:
command
];
}];
}];
...
@@ -210,7 +210,7 @@
...
@@ -210,7 +210,7 @@
{
{
[
self
.
commandDelegate
runInBackground
:
^
{
[
self
.
commandDelegate
runInBackground
:
^
{
[
_center
cancelAllNotifications
];
[
_center
cancelAllNotifications
];
[
_app
setApplicationIconBadgeNumber
:
0
];
[
self
clearApplicationIconBadgeNumber
];
[
self
fireEvent
:
@"cancelall"
];
[
self
fireEvent
:
@"cancelall"
];
[
self
execCallback
:
command
];
[
self
execCallback
:
command
];
}];
}];
...
@@ -560,17 +560,44 @@
...
@@ -560,17 +560,44 @@
-
(
void
)
pluginInitialize
-
(
void
)
pluginInitialize
{
{
eventQueue
=
[[
NSMutableArray
alloc
]
init
];
eventQueue
=
[[
NSMutableArray
alloc
]
init
];
_app
=
[
UIApplication
sharedApplication
];
_center
=
[
UNUserNotificationCenter
currentNotificationCenter
];
_center
=
[
UNUserNotificationCenter
currentNotificationCenter
];
_center
.
delegate
=
self
;
_center
.
delegate
=
self
;
[
_center
registerGeneralNotificationCategory
];
[
_center
registerGeneralNotificationCategory
];
[
self
monitorAppStateChanges
];
}
/**
* Monitor changes of the app state and update the _isActive flag.
*/
-
(
void
)
monitorAppStateChanges
{
NSNotificationCenter
*
center
=
[
NSNotificationCenter
defaultCenter
];
[
center
addObserverForName
:
UIApplicationDidBecomeActiveNotification
object
:
NULL
queue
:
[
NSOperationQueue
mainQueue
]
usingBlock
:^
(
NSNotification
*
e
)
{
isActive
=
YES
;
}];
[
center
addObserverForName
:
UIApplicationDidEnterBackgroundNotification
object
:
NULL
queue
:
[
NSOperationQueue
mainQueue
]
usingBlock
:^
(
NSNotification
*
e
)
{
isActive
=
NO
;
}];
}
}
#pragma mark -
#pragma mark -
#pragma mark Helper
#pragma mark Helper
/**
/**
* Removes the badge number from the app icon.
*/
-
(
void
)
clearApplicationIconBadgeNumber
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[[
UIApplication
sharedApplication
]
setApplicationIconBadgeNumber
:
0
];
});
}
/**
* Simply invokes the callback without any parameter.
* Simply invokes the callback without any parameter.
*/
*/
-
(
void
)
execCallback
:
(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
execCallback
:
(
CDVInvokedUrlCommand
*
)
command
...
@@ -625,7 +652,6 @@
...
@@ -625,7 +652,6 @@
notification
:
(
UNNotificationRequest
*
)
request
notification
:
(
UNNotificationRequest
*
)
request
data
:
(
NSMutableDictionary
*
)
data
data
:
(
NSMutableDictionary
*
)
data
{
{
BOOL
isActive
=
[
_app
applicationState
]
==
UIApplicationStateActive
;
NSString
*
js
,
*
params
,
*
notiAsJSON
,
*
dataAsJSON
;
NSString
*
js
,
*
params
,
*
notiAsJSON
,
*
dataAsJSON
;
NSData
*
dataAsData
;
NSData
*
dataAsData
;
...
...
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