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
620d3fc4
Commit
620d3fc4
authored
Nov 09, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added wakeup options for Android [See #627]
parent
cf99f31e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
5 deletions
+48
-5
README.md
README.md
+1
-1
plugin.xml
plugin.xml
+1
-0
TriggerReceiver.java
src/android/TriggerReceiver.java
+36
-2
Options.java
src/android/notification/Options.java
+8
-1
local-notification-util.js
www/local-notification-util.js
+2
-1
No files found.
README.md
View file @
620d3fc4
...
...
@@ -98,7 +98,7 @@ A notification does have a set of configurable properties. Not all of them are s
| id | data | actionGroupId | summary | led | showWhen | channel | actions |
| text | icon | attachments | smallIcon | color | defaults | launch | groupSummary |
| title | silent | progressBar | sticky | vibrate | priority | mediaSession | foreground |
| sound | trigger | group | autoClear | lockscreen | number | badge |
| sound | trigger | group | autoClear | lockscreen | number | badge |
wakeup |
For their default values see:
...
...
plugin.xml
View file @
620d3fc4
...
...
@@ -140,6 +140,7 @@
<config-file
target=
"AndroidManifest.xml"
parent=
"/manifest"
>
<!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> -->
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
</config-file>
<source-file
...
...
src/android/TriggerReceiver.java
View file @
620d3fc4
...
...
@@ -21,13 +21,19 @@
package
de
.
appplant
.
cordova
.
plugin
.
localnotification
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.os.PowerManager
;
import
de.appplant.cordova.plugin.notification.Builder
;
import
de.appplant.cordova.plugin.notification.Manager
;
import
de.appplant.cordova.plugin.notification.Notification
;
import
de.appplant.cordova.plugin.notification.Options
;
import
de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver
;
import
static
android
.
content
.
Context
.
POWER_SERVICE
;
import
static
android
.
os
.
PowerManager
.
RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY
;
/**
* The alarm receiver is triggered when a scheduled alarm is fired. This class
* reads the information in the intent and displays this information in the
...
...
@@ -46,10 +52,16 @@ public class TriggerReceiver extends AbstractTriggerReceiver {
@Override
public
void
onTrigger
(
Notification
notification
,
Bundle
bundle
)
{
boolean
isUpdate
=
bundle
.
getBoolean
(
Notification
.
EXTRA_UPDATE
,
false
);
int
badge
=
notification
.
getOptions
().
getBadgeNumber
();
Context
context
=
notification
.
getContext
();
Options
options
=
notification
.
getOptions
();
int
badge
=
options
.
getBadgeNumber
();
if
(
badge
>
0
)
{
Manager
.
getInstance
(
notification
.
getContext
()).
setBadge
(
badge
);
Manager
.
getInstance
(
context
).
setBadge
(
badge
);
}
if
(
options
.
shallWakeUp
())
{
wakeUp
(
context
);
}
notification
.
show
();
...
...
@@ -60,6 +72,28 @@ public class TriggerReceiver extends AbstractTriggerReceiver {
}
/**
* Wakeup the device.
*
* @param context The application context.
*/
private
void
wakeUp
(
Context
context
)
{
PowerManager
pm
=
(
PowerManager
)
context
.
getSystemService
(
POWER_SERVICE
);
if
(
pm
==
null
)
return
;
int
level
=
PowerManager
.
SCREEN_DIM_WAKE_LOCK
|
PowerManager
.
ACQUIRE_CAUSES_WAKEUP
;
PowerManager
.
WakeLock
wakeLock
=
pm
.
newWakeLock
(
level
,
"LocalNotification"
);
wakeLock
.
setReferenceCounted
(
false
);
wakeLock
.
acquire
(
1000
);
wakeLock
.
release
(
RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY
);
}
/**
* Build notification specified by options.
*
* @param builder Notification builder.
...
...
src/android/notification/Options.java
View file @
620d3fc4
...
...
@@ -193,6 +193,13 @@ public final class Options {
}
/**
* wakeup flag for the notification.
*/
public
boolean
shallWakeUp
()
{
return
options
.
optBoolean
(
"wakeup"
,
true
);
}
/**
* The channel id of that notification.
*/
String
getChannel
()
{
...
...
@@ -335,7 +342,7 @@ public final class Options {
/**
* Icon resource ID for the local notification.
*/
public
boolean
hasLargeIcon
()
{
boolean
hasLargeIcon
()
{
String
icon
=
options
.
optString
(
"icon"
,
null
);
return
icon
!=
null
;
}
...
...
www/local-notification-util.js
View file @
620d3fc4
...
...
@@ -54,7 +54,8 @@ exports._defaults = {
text
:
''
,
title
:
''
,
trigger
:
{
type
:
'calendar'
},
vibrate
:
false
vibrate
:
false
,
wakeup
:
true
};
// Listener
...
...
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