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
8950fdeb
Commit
8950fdeb
authored
Mar 16, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GET_TASK permission not needed anymore for Android (solves #123)
parent
3b624527
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
16 deletions
+31
-16
CHANGELOG.md
CHANGELOG.md
+1
-0
plugin.xml
plugin.xml
+0
-1
LocalNotification.java
src/android/LocalNotification.java
+16
-15
local-notification.js
www/local-notification.js
+14
-0
No files found.
CHANGELOG.md
View file @
8950fdeb
...
...
@@ -10,6 +10,7 @@
-
[
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.
-
[
enhancement:
]
GET_TASK permission not needed anymore for Android.
#### Version 0.7.2 (09.02.2014)
-
[
enhancement:
]
Avoid blocking the main thread (on Android)
**(dpogue)**
.
...
...
plugin.xml
View file @
8950fdeb
...
...
@@ -74,7 +74,6 @@
</config-file>
<config-file
target=
"AndroidManifest.xml"
parent=
"/manifest"
>
<uses-permission
android:name=
"android.permission.GET_TASKS"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
</config-file>
...
...
src/android/LocalNotification.java
View file @
8950fdeb
...
...
@@ -34,7 +34,6 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
android.app.ActivityManager
;
import
android.app.AlarmManager
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
...
...
@@ -56,7 +55,7 @@ public class LocalNotification extends CordovaPlugin {
private
static
CordovaWebView
webView
=
null
;
private
static
Boolean
deviceready
=
false
;
protected
static
Context
context
=
null
;
protected
static
Boolean
isInBackground
=
true
;
private
static
ArrayList
<
String
>
eventQueue
=
new
ArrayList
<
String
>();
@Override
...
...
@@ -131,6 +130,18 @@ public class LocalNotification extends CordovaPlugin {
return
true
;
}
if
(
action
.
equalsIgnoreCase
(
"pause"
))
{
isInBackground
=
true
;
return
true
;
}
if
(
action
.
equalsIgnoreCase
(
"resume"
))
{
isInBackground
=
false
;
return
true
;
}
// Returning false results in a "MethodNotFound" error.
return
false
;
}
...
...
@@ -306,10 +317,12 @@ 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
=
isInBackground
?
"background"
:
"foreground"
;
String
params
=
"\""
+
id
+
"\",\""
+
state
+
"\",\\'"
+
JSONObject
.
quote
(
json
)
+
"\\'.replace(/(^\"|\"$)/g, \\'\\')"
;
String
js
=
"setTimeout('plugin.notification.local.on"
+
event
+
"("
+
params
+
")',0)"
;
// webview may available, but callbacks needs to be executed
// after deviceready
if
(
deviceready
==
false
)
{
eventQueue
.
add
(
js
);
}
else
{
...
...
@@ -346,15 +359,4 @@ public class LocalNotification extends CordovaPlugin {
protected
static
NotificationManager
getNotificationManager
()
{
return
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
}
/**
* Specifies whether the App is running in the background
*/
private
static
boolean
isInBackground
()
{
try
{
return
!
context
.
getPackageName
().
equalsIgnoreCase
(((
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
)).
getRunningTasks
(
1
).
get
(
0
).
topActivity
.
getPackageName
());
}
catch
(
Exception
e
)
{
return
true
;
}
}
}
\ No newline at end of file
www/local-notification.js
View file @
8950fdeb
...
...
@@ -216,4 +216,18 @@ channel.deviceready.subscribe( function () {
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'deviceready'
,
[]);
});
channel
.
onCordovaReady
.
subscribe
(
function
()
{
if
(
device
.
platform
!=
'iOS'
)
{
channel
.
onPause
.
subscribe
(
function
()
{
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'pause'
,
[]);
});
channel
.
onResume
.
subscribe
(
function
()
{
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'resume'
,
[]);
});
cordova
.
exec
(
null
,
null
,
'LocalNotification'
,
'resume'
,
[]);
}
});
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