react-native-push-notification: Local Notifications not working on Android Oreo (target SDK 26)

Problem: Notifications are working fine on iOS, but when I run the app on my Android device with Oreo I get no notifications and the following error in my logs:

12-08 13:19:23.423 4324 26687 E NotificationService: No Channel found for pkg=com.saferackexample, channelId=null, id=1222192301, tag=null, opPkg=com.saferackexample, callingUid=10196, userId=0, incomingUserId=0, notificationUid=10196, notification=Notification(channel=null pri=1 contentView=null vibrate=[0,300] sound=content://settings/system/notification_sound defaults=0x4 flags=0x10 color=0x00000000 category=call vis=PRIVATE)

compileSdkVersion:` 26, buildToolsVersion: 26.0.02,

build.gradle dependencies:

dependencies {
    compile project(':react-native-push-notification')
    compile(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
      }
    compile project(':react-native-background-geolocation')
    compile(name: 'tslocationmanager', ext: 'aar')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26.1.0"
    compile "com.facebook.react:react-native:+"  // From node_modules
    
    compile ("com.google.android.gms:play-services-base:11.6.0") {
        force = true;
    }
    compile ("com.google.android.gms:play-services-maps:11.6.0") {
        force = true;
    }
    compile ("com.google.android.gms:play-services-gcm:11.6.0") {
        force = true;
    }
    compile ("com.google.android.gms:play-services-location:11.6.0") {
        force = true;
    }
}

I installed the package exactly as described in the repo and I’m only looking to use local notifications in my app. Has anyone come across this or have a possible solution?

Thank you very much for your assistance.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 16 (1 by maintainers)

Most upvoted comments

For anyone else struggling with this. I got around this issue by downgrade my target sdk version to 25. Not ideal but works until a proper fix is merged in.

In app/build.gradle

...
targetSdkVersion 25
...

Add Notification Chanel in MainActivity.java

public void onResume() {
        super.onResume();
        NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            int importance = NotificationManager.IMPORTANCE_HIGH;

            NotificationChannel notificationChannel = new NotificationChannel("appChannel", "appchannel", importance);
            notificationChannel.enableLights(true);
            notificationChannel.setLightColor(Color.RED);
            notificationChannel.enableVibration(true);
            notificationChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
            nMgr.createNotificationChannel(notificationChannel);
        }

        nMgr.cancelAll();
    }

For Android Oreo support on localNotification, I added these lines in manifest

<application ... >

    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
        android:value="YOUR NOTIFICATION CHANNEL NAME"/>

    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
        android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>

    <!-- Change the resource name to your App's accent color - or any other color you want -->
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
        android:resource="@android:color/white"/>

    ...

as mentioned in localNotificationSchedule configuration here

This PR should fix the problem. You can also change targetSdkVersion to 25 as mentioned above.

Same for me, local notification not working in oreo

PR #657 was merged some days ago. Can you check it’s working well on Oreo by using the package from github directly ? We will release a npm package when we are sure it’s working well for everyone.

Same issue… +1