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
d5c0072c
Commit
d5c0072c
authored
Nov 16, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for Android 4.4 and Android 5+
parent
77ecc164
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
12 deletions
+26
-12
Manager.java
src/android/notification/Manager.java
+16
-9
Notification.java
src/android/notification/Notification.java
+10
-3
No files found.
src/android/notification/Manager.java
View file @
d5c0072c
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
package
de
.
appplant
.
cordova
.
plugin
.
notification
;
package
de
.
appplant
.
cordova
.
plugin
.
notification
;
import
android.annotation.SuppressLint
;
import
android.app.NotificationChannel
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.app.NotificationManager
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -38,6 +39,7 @@ import java.util.Set;
...
@@ -38,6 +39,7 @@ import java.util.Set;
import
de.appplant.cordova.plugin.badge.BadgeImpl
;
import
de.appplant.cordova.plugin.badge.BadgeImpl
;
import
static
android
.
os
.
Build
.
VERSION
.
SDK_INT
;
import
static
android
.
os
.
Build
.
VERSION
.
SDK_INT
;
import
static
android
.
os
.
Build
.
VERSION_CODES
.
M
;
import
static
android
.
os
.
Build
.
VERSION_CODES
.
O
;
import
static
android
.
os
.
Build
.
VERSION_CODES
.
O
;
import
static
android
.
support
.
v4
.
app
.
NotificationManagerCompat
.
IMPORTANCE_DEFAULT
;
import
static
android
.
support
.
v4
.
app
.
NotificationManagerCompat
.
IMPORTANCE_DEFAULT
;
import
static
de
.
appplant
.
cordova
.
plugin
.
notification
.
Notification
.
PREF_KEY_ID
;
import
static
de
.
appplant
.
cordova
.
plugin
.
notification
.
Notification
.
PREF_KEY_ID
;
...
@@ -103,6 +105,7 @@ public final class Manager {
...
@@ -103,6 +105,7 @@ public final class Manager {
/**
/**
* TODO: temporary
* TODO: temporary
*/
*/
@SuppressLint
(
"WrongConstant"
)
private
void
createDefaultChannel
()
{
private
void
createDefaultChannel
()
{
NotificationManager
mgr
=
getNotMgr
();
NotificationManager
mgr
=
getNotMgr
();
...
@@ -224,8 +227,8 @@ public final class Manager {
...
@@ -224,8 +227,8 @@ public final class Manager {
if
(
type
==
Notification
.
Type
.
ALL
)
if
(
type
==
Notification
.
Type
.
ALL
)
return
getIds
();
return
getIds
();
StatusBarNotification
[]
activeToasts
=
get
NotMgr
().
get
ActiveNotifications
();
StatusBarNotification
[]
activeToasts
=
getActiveNotifications
();
List
<
Integer
>
activeIds
=
new
ArrayList
<
Integer
>();
List
<
Integer
>
activeIds
=
new
ArrayList
<
Integer
>();
for
(
StatusBarNotification
toast
:
activeToasts
)
{
for
(
StatusBarNotification
toast
:
activeToasts
)
{
activeIds
.
add
(
toast
.
getId
());
activeIds
.
add
(
toast
.
getId
());
...
@@ -390,6 +393,17 @@ public final class Manager {
...
@@ -390,6 +393,17 @@ public final class Manager {
}
}
/**
/**
* Get all active status bar notifications.
*/
StatusBarNotification
[]
getActiveNotifications
()
{
if
(
SDK_INT
>=
M
)
{
return
getNotMgr
().
getActiveNotifications
();
}
else
{
return
new
StatusBarNotification
[
0
];
}
}
/**
* Shared private preferences for the application.
* Shared private preferences for the application.
*/
*/
private
SharedPreferences
getPrefs
()
{
private
SharedPreferences
getPrefs
()
{
...
@@ -411,11 +425,4 @@ public final class Manager {
...
@@ -411,11 +425,4 @@ public final class Manager {
return
NotificationManagerCompat
.
from
(
context
);
return
NotificationManagerCompat
.
from
(
context
);
}
}
/**
* Notification manager compat for the application.
*/
private
NotificationManagerCompat
getNotMgrCompat
()
{
return
NotificationManagerCompat
.
from
(
context
);
}
}
}
src/android/notification/Notification.java
View file @
d5c0072c
...
@@ -46,6 +46,8 @@ import java.util.Set;
...
@@ -46,6 +46,8 @@ import java.util.Set;
import
static
android
.
app
.
AlarmManager
.
RTC
;
import
static
android
.
app
.
AlarmManager
.
RTC
;
import
static
android
.
app
.
AlarmManager
.
RTC_WAKEUP
;
import
static
android
.
app
.
AlarmManager
.
RTC_WAKEUP
;
import
static
android
.
app
.
PendingIntent
.
FLAG_CANCEL_CURRENT
;
import
static
android
.
app
.
PendingIntent
.
FLAG_CANCEL_CURRENT
;
import
static
android
.
os
.
Build
.
VERSION
.
SDK_INT
;
import
static
android
.
os
.
Build
.
VERSION_CODES
.
M
;
import
static
android
.
support
.
v4
.
app
.
NotificationManagerCompat
.
IMPORTANCE_MAX
;
import
static
android
.
support
.
v4
.
app
.
NotificationManagerCompat
.
IMPORTANCE_MAX
;
import
static
android
.
support
.
v4
.
app
.
NotificationManagerCompat
.
IMPORTANCE_MIN
;
import
static
android
.
support
.
v4
.
app
.
NotificationManagerCompat
.
IMPORTANCE_MIN
;
...
@@ -138,8 +140,9 @@ public final class Notification {
...
@@ -138,8 +140,9 @@ public final class Notification {
* Notification type can be one of triggered or scheduled.
* Notification type can be one of triggered or scheduled.
*/
*/
public
Type
getType
()
{
public
Type
getType
()
{
StatusBarNotification
[]
toasts
=
getNotMgr
().
getActiveNotifications
();
Manager
mgr
=
Manager
.
getInstance
(
context
);
int
id
=
getId
();
StatusBarNotification
[]
toasts
=
mgr
.
getActiveNotifications
();
int
id
=
getId
();
for
(
StatusBarNotification
toast
:
toasts
)
{
for
(
StatusBarNotification
toast
:
toasts
)
{
if
(
toast
.
getId
()
==
id
)
{
if
(
toast
.
getId
()
==
id
)
{
...
@@ -202,7 +205,11 @@ public final class Notification {
...
@@ -202,7 +205,11 @@ public final class Notification {
mgr
.
setExact
(
RTC
,
time
,
pi
);
mgr
.
setExact
(
RTC
,
time
,
pi
);
break
;
break
;
case
IMPORTANCE_MAX:
case
IMPORTANCE_MAX:
mgr
.
setExactAndAllowWhileIdle
(
RTC_WAKEUP
,
time
,
pi
);
if
(
SDK_INT
>=
M
)
{
mgr
.
setExactAndAllowWhileIdle
(
RTC_WAKEUP
,
time
,
pi
);
}
else
{
mgr
.
setExact
(
RTC
,
time
,
pi
);
}
break
;
break
;
default
:
default
:
mgr
.
setExact
(
RTC_WAKEUP
,
time
,
pi
);
mgr
.
setExact
(
RTC_WAKEUP
,
time
,
pi
);
...
...
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