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
715484fc
Commit
715484fc
authored
Mar 16, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method to retrieve the application state on each platform
parent
2b8b21a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
+31
-7
LocalNotification.java
src/android/LocalNotification.java
+11
-1
APPLocalNotification.m
src/ios/APPLocalNotification.m
+20
-6
No files found.
src/android/LocalNotification.java
View file @
715484fc
...
...
@@ -317,7 +317,7 @@ public class LocalNotification extends CordovaPlugin {
* @param {String} json A custom (JSON) string
*/
public
static
void
fireEvent
(
String
event
,
String
id
,
String
json
)
{
String
state
=
isInBackground
?
"background"
:
"foreground"
;
String
state
=
getApplicationState
()
;
String
params
=
"\""
+
id
+
"\",\""
+
state
+
"\",\\'"
+
JSONObject
.
quote
(
json
)
+
"\\'.replace(/(^\"|\"$)/g, \\'\\')"
;
String
js
=
"setTimeout('plugin.notification.local.on"
+
event
+
"("
+
params
+
")',0)"
;
...
...
@@ -331,6 +331,16 @@ public class LocalNotification extends CordovaPlugin {
}
/**
* Retrieves the application state
*
* @return {String}
* Either "background" or "foreground"
*/
protected
static
String
getApplicationState
()
{
return
isInBackground
?
"background"
:
"foreground"
;
}
/**
* Set the application context if not already set.
*/
protected
static
void
setContext
(
Context
context
)
{
...
...
src/ios/APPLocalNotification.m
View file @
715484fc
...
...
@@ -49,6 +49,8 @@
-
(
BOOL
)
isNotificationScheduledWithId
:(
NSString
*
)
id
;
// Retrieves the local notification by its ID
-
(
UILocalNotification
*
)
notificationWithId
:(
NSString
*
)
id
;
// Retrieves the application state
-
(
NSString
*
)
applicationState
;
// Fires the given event
-
(
void
)
fireEvent
:(
NSString
*
)
event
id
:(
NSString
*
)
id
json
:(
NSString
*
)
json
;
...
...
@@ -514,6 +516,22 @@
}
/**
* Retrieves the application state
*
* @return {NSString}
* Either "background" or "foreground"
*/
-
(
NSString
*
)
applicationState
{
UIApplicationState
state
=
[[
UIApplication
sharedApplication
]
applicationState
];
bool
isActive
=
state
==
UIApplicationStateActive
;
return
isActive
?
@"foreground"
:
@"background"
;
}
/**
* Fires the given event.
*
* @param {NSString} event
...
...
@@ -525,15 +543,11 @@
*/
-
(
void
)
fireEvent
:
(
NSString
*
)
event
id
:
(
NSString
*
)
id
json
:
(
NSString
*
)
json
{
UIApplicationState
state
=
[[
UIApplication
sharedApplication
]
applicationState
];
bool
isActive
=
state
==
UIApplicationStateActive
;
NSString
*
stateName
=
isActive
?
@"foreground"
:
@"background"
;
NSString
*
appState
=
[
self
applicationState
];
NSString
*
params
=
[
NSString
stringWithFormat
:
@"
\"
%@
\"
,
\"
%@
\"
,
\\
'%@
\\
'"
,
id
,
stateNam
e
,
json
];
id
,
appStat
e
,
json
];
NSString
*
js
=
[
NSString
stringWithFormat
:
@"setTimeout('plugin.notification.local.on%@(%@)',0)"
,
...
...
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