Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I fixed the issue about android 8+ not work led and vibrate #1668

Open
jevian-ma opened this issue Aug 26, 2018 · 7 comments
Open

I fixed the issue about android 8+ not work led and vibrate #1668

jevian-ma opened this issue Aug 26, 2018 · 7 comments

Comments

@jevian-ma
Copy link

at the android 8+, NotificationChannel need to set enableLights and enableVibration.
I make a patch to fixed it as follow:

diff --git a/src/android/TriggerReceiver.java b/src/android/TriggerReceiver.java
index 19c4eea..cc5915b 100644
--- a/src/android/TriggerReceiver.java
+++ b/src/android/TriggerReceiver.java
@@ -67,6 +67,8 @@ public class TriggerReceiver extends AbstractTriggerReceiver {
             wakeUp(context);
         }
 
+        manager.createDefaultChannel(options.getDict().optBoolean("led", true), options.getDict().optBoolean("vibrate", true));
+
         notification.show();
 
         if (options.isInfiniteTrigger()) {
diff --git a/src/android/notification/Manager.java b/src/android/notification/Manager.java
index c456597..769ef07 100644
--- a/src/android/notification/Manager.java
+++ b/src/android/notification/Manager.java
@@ -68,7 +68,6 @@ public final class Manager {
      */
     private Manager(Context context) {
         this.context = context;
-        createDefaultChannel();
     }
 
     /**
@@ -106,7 +105,7 @@ public final class Manager {
      * TODO: temporary
      */
     @SuppressLint("WrongConstant")
-    private void createDefaultChannel() {
+    public void createDefaultChannel(Boolean enablelights, Boolean enablevibration) {
         NotificationManager mgr = getNotMgr();
 
         if (SDK_INT < O)
@@ -119,6 +118,8 @@ public final class Manager {
 
         channel = new NotificationChannel(
                 CHANNEL_ID, CHANNEL_NAME, IMPORTANCE_DEFAULT);
+        channel.enableLights(enablelights);
+        channel.enableVibration(enablevibration);
 
         mgr.createNotificationChannel(channel);
     }

please to commit it, thank you.

@phiamo
Copy link

phiamo commented Sep 7, 2018

+1

2 similar comments
@angel1st
Copy link

+1

@Wobow
Copy link

Wobow commented Sep 18, 2018

+1

@HartzDev
Copy link

Hi, @jevian-ma ,
Do this plugin work on your android 8.0?
i make some notifs. and its not working in android 8.0.
no notification called , no sound, infact the plugin set the notif.

@shahkeyur
Copy link

shahkeyur commented Oct 1, 2018

Hi, @jevian-ma ,
Do this plugin work on your android 8.0?
i make some notifs. and its not working in android 8.0.
no notification called , no sound, infact the plugin set the notif.

Hi @HartzDev
Yes it works. I have tested it on multiple 8.0 devices
Try installing plugin from my repository. . I have modified it for Android 8.0

@HartzDev
Copy link

thx @shahkeyur ,
i will try. :D

@HartzDev
Copy link

@shahkeyur , i have try ur code, notif i shown, but no custom sound .
do i have to use Ringtone class for Oreo smartphone? thx in advanced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants