React-native-push-notification: [Android] Local Scheduled Notification not working in Android 9

Created on 4 Feb 2019  Â·  4Comments  Â·  Source: zo0r/react-native-push-notification

Local Schedule Notification are not working properly in Android Pie.
It is working when the App is in the Background. But it doesn't work than the App is removed from the background or from memory

` package="com.jainniyams">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <!-- < Only if you're using GCM or localNotificationSchedule() > -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
    android:name="${applicationId}.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />



<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:allowBackup="false"
  android:theme="@style/AppTheme">

  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
            android:value="rn-push-notification-channel-id"/>
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
                android:value="REMINDER-CHANNEL-DESCRIPTION"/>

                <!-- < Only if you're using GCM or localNotificationSchedule() > -->
    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="${applicationId}" />
        </intent-filter>
    </receiver>

    <!-- < Only if you're using GCM or localNotificationSchedule() > -->

    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
    <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>

    <!-- < Only if you're using GCM or localNotificationSchedule() > -->
    <service
        android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>

            <service
        android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>


  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:launchMode="singleTop"
    android:windowSoftInputMode="adjustPan">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />




</application>


`

`buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}`

Most helpful comment

@zo0r it's still not working for me nor localNotification neither localNotificationSchedule. It wasworking on android 8 though on same samsung s8 device.

All 4 comments

Issue Resolved

Works Perfectly

Solution: The Problem was the OS. In Oneplus the app was in the Battery Optimization when the Battery Optimization was disabled for the App the notification worked perfectly even after closing the app

@zo0r it's still not working for me nor localNotification neither localNotificationSchedule. It wasworking on android 8 though on same samsung s8 device.

@mujtabazaidi downgrade the version of ‘react-native-push-notification’ to ‘3.1.2’

Issue Resolved

Works Perfectly

Solution: The Problem was the OS. In Oneplus the app was in the Battery Optimization when the Battery Optimization was disabled for the App the notification worked perfectly even after closing the app

Turns out my entire day was wasted because of of Oneplus battery optimisation! Thanks @sagarv1997

Was this page helpful?
0 / 5 - 0 ratings