question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local Notifications not working in android

See original GitHub issue

I have been trying the Scheduled local notifications but not a single notification is being triggered. I am not able to find exactly where I am doing mistake.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.notes">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@drawable/ic_launcher"
  android:roundIcon="@drawable/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/BootTheme">

  <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" android:exported="false"/>
  <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" android:exported="false"/>
  <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" android:exported="false">
      <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED" />
          <action android:name="android.intent.action.QUICKBOOT_POWERON" />
          <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
      </intent-filter>
  </receiver>

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

  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
              android:value="false"/>
  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
              android:resource="@android:color/white"/>

  
  
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustResize"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  
  
</application>
</manifest>

import PushNotification, {Importance} from ‘react-native-push-notification’; import {CONSTANTS} from ‘…/…/constants’;

export default class NotificationService { static configure() {} static createChannel() { PushNotification.channelExists( CONSTANTS.NOTIFICATION_CHANNEL_ID, exists => { if (exists) { console.log( createChannel ${CONSTANTS.NOTIFICATION_CHANNEL_ID} already exists, ); } else { PushNotification.createChannel( { channelId: CONSTANTS.NOTIFICATION_CHANNEL_ID, channelName: ‘Notes channel’, channelDescription: ‘Notes notification channel’, playSound: true, soundName: ‘default’, importance: Importance.HIGH, vibrate: true, }, created => console.log(createChannel returned '${created}'), ); } }, ); } static getAllScheduledNotifications() { PushNotification.getScheduledLocalNotifications(notifications => { console.log(notifications); }); } static scheduleNotification({notificationID, title, description, timestamp}) { PushNotification.localNotificationSchedule({ date: new Date(timestamp), channelId: CONSTANTS.NOTIFICATION_CHANNEL_ID, id: notificationID, vibrate: true, vibration: 300, title: title, message: description, playSound: true, soundName: ‘default’, }); } static cancelNotification(notificationID) { PushNotification.cancelLocalNotification(notificationID); } }

Is there any thing more which we need to change?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
ragsavcommented, Sep 22, 2022

@roma-hladilka Still no notifications. Also I am not able to receive normal notifications.

0reactions
Sergey-langcommented, Nov 28, 2022

Work at first times, but then not. I see that I received push, but it work and show only if app is closed(background). if reinstall package it work again. What’s wrong?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Local notifications not working how to fix it - Stack Overflow
1 Answer 1 ; extends AppCompatActivity · public ; = "channel_id" · public ; = "Notification Channel" · public ; = 101 ·...
Read more >
Android Notifications Not Showing Up? 10 Fixes You Can Try
Android Notifications Not Showing Up? 10 Fixes You Can Try · 1. Reboot Your Phone · 2. Review the App's Notification Settings ·...
Read more >
[Local Notifications Plugin] Notifications not showing on Android
I tried to use this plugin but, although notifications are showing as expected on iOS, they don't show on Android (8.1.0)? Anyone with...
Read more >
Local Notifications Capacitor Plugin API
The notification identifier. On Android it's a 32-bit int. So the value should be between -2147483648 and 2147483647 inclusive. 1.0.0. schedule ...
Read more >
Notifications Not Shown - Mobile Push
Android App is Force Stopped ; MIUI 10, Settings > Battery & performance > Choose apps > Select the app that is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found