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
519c452b
Commit
519c452b
authored
Oct 18, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic support for channels for Android 8
parent
773bf72b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
4 deletions
+46
-4
Builder.java
src/android/notification/Builder.java
+2
-1
Manager.java
src/android/notification/Manager.java
+36
-3
Options.java
src/android/notification/Options.java
+7
-0
local-notification-util.js
www/local-notification-util.js
+1
-0
No files found.
src/android/notification/Builder.java
View file @
519c452b
...
...
@@ -95,8 +95,9 @@ public final class Builder {
return
new
Notification
(
context
,
options
);
}
builder
=
new
NotificationCompat
.
Builder
(
context
,
"channel"
)
builder
=
new
NotificationCompat
.
Builder
(
context
,
Manager
.
CHANNEL_ID
)
.
setDefaults
(
options
.
getDefaults
())
.
setChannelId
(
options
.
getChannel
())
.
setContentTitle
(
options
.
getTitle
())
.
setContentText
(
options
.
getText
())
.
setTicker
(
options
.
getText
())
...
...
src/android/notification/Manager.java
View file @
519c452b
...
...
@@ -22,13 +22,14 @@
package
de
.
appplant
.
cordova
.
plugin
.
notification
;
import
android.app.AlarmManager
;
import
android.app.NotificationChannel
Group
;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.support.v4.app.NotificationManagerCompat
;
...
...
@@ -44,6 +45,10 @@ import java.util.Set;
import
de.appplant.cordova.plugin.notification.receiver.TriggerReceiver
;
import
static
android
.
os
.
Build
.
VERSION
.
SDK_INT
;
import
static
android
.
os
.
Build
.
VERSION_CODES
.
O
;
import
static
android
.
support
.
v4
.
app
.
NotificationManagerCompat
.
IMPORTANCE_DEFAULT
;
// import static de.appplant.cordova.plugin.notification.Notification.PREF_KEY;
/**
...
...
@@ -53,7 +58,13 @@ import de.appplant.cordova.plugin.notification.receiver.TriggerReceiver;
*/
public
final
class
Manager
{
// Context passed through constructor and used for notification builder.
// TODO: temporary
static
final
String
CHANNEL_ID
=
"default-channel-id"
;
// TODO: temporary
private
static
final
CharSequence
CHANNEL_NAME
=
"Default channel"
;
// The application context
private
Context
context
;
/**
...
...
@@ -61,8 +72,9 @@ public final class Manager {
*
* @param context Application context
*/
private
Manager
(
Context
context
){
private
Manager
(
Context
context
)
{
this
.
context
=
context
;
createDefaultChannel
();
}
/**
...
...
@@ -141,6 +153,27 @@ public final class Manager {
return
true
;
}
/**
* TODO: temporary
*/
private
void
createDefaultChannel
()
{
NotificationManager
mgr
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
if
(
SDK_INT
<
O
)
return
;
NotificationChannel
channel
=
mgr
.
getNotificationChannel
(
CHANNEL_ID
);
if
(
channel
!=
null
)
return
;
channel
=
new
NotificationChannel
(
CHANNEL_ID
,
CHANNEL_NAME
,
IMPORTANCE_DEFAULT
);
mgr
.
createNotificationChannel
(
channel
);
}
// /**
// * Clear local notification specified by ID.
// *
...
...
src/android/notification/Options.java
View file @
519c452b
...
...
@@ -173,6 +173,13 @@ public final class Options {
}
/**
* The channel id of that notification.
*/
String
getChannel
()
{
return
options
.
optString
(
"channel"
,
Manager
.
CHANNEL_ID
);
}
/**
* If the group shall show a summary.
*/
boolean
getGroupSummary
()
{
...
...
www/local-notification-util.js
View file @
519c452b
...
...
@@ -66,6 +66,7 @@ exports.applyPlatformSpecificOptions = function () {
defaults
.
showWhen
=
true
;
defaults
.
defaults
=
0
;
defaults
.
priority
=
0
;
defaults
.
channel
=
undefined
;
break
;
}
};
...
...
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