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.

No notification and no native alarm

See original GitHub issue

I’ve gone through all the issues and can’t tell why I’m the only one who can’t get the alarm to work. If I call all the other methods like cancelAllNotifications(), getScheduledAlarms, I get expected values logged. When I try calling sendNotification and scheduleAlarm, I get neither error nor notification. Also checking my phone’s alarm shows nothing was set, meaning it isn’t a notifications issue alone. What could the problem be?

I have this at the tail end of my imports


import android.app.NotificationManager;
import android.app.NotificationChannel;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;

And this inside the onCreate method public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false);

String id = "bvm_id";          // The id of the channel.
CharSequence name = "BVM";      // The user-visible name of the channel.
String description = "Bible_Memorization_Alarm";  // The user-visible description of the channel.

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  NotificationChannel mChannel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_DEFAULT);

  // Configure the notification channel. 
  mChannel.setDescription(description);

  mChannel.enableLights(true);
  // Sets the notification light color for notifications posted to this
  // channel, if the device supports this feature. 
  mChannel.setLightColor(Color.RED);

  mChannel.enableVibration(true);
  mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});

  NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.createNotificationChannel(mChannel);
}

}

I have the following android manifest

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

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

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize">
        <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" />
      <service android:name="com.emekalites.react.alarm.notification.ANService" android:enabled="true"/>
        <receiver android:name="com.emekalites.react.alarm.notification.ANAlarmReceiver" android:enabled="true"/>
        <receiver android:name="com.emekalites.react.alarm.notification.ANBootReceiver" android:enabled="true" android:exported="true">
            <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>
    </application>

</manifest>

I linked the package after installing it, and crosschecked with manual linking. The only step I didn’t follow is the one in the MainActivity.java file which I can’t find imports for. Is that why it doesn’t work?

What other info do you need to reproduce the error? Version 1.2.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nmeri17commented, Jan 26, 2019

But then again String id = “bvm_id”; // The id of the channel. is not the same with what you have here channel: “emaw_bvm_id”, in your alarmNotifData. They have to be the same.

Right. That was deliberate obfuscation to prevent the app’s Google searches from leading here.

I was facing the threat of the client cancelling the project at the time of opening this issue and your replies weren’t rapid so I resorted to another module. Maybe if I’d seen the examples folder earlier, things would’ve been different. Thanks for trying to help.

PS: You’re doing a great job

0reactions
nmeri17commented, Feb 5, 2019

Gave this another shot by comparing and copying your examples folder verbatim and it worked smoothly! I think the major reason my implementation couldn’t get off the ground was, the docs don’t mention the need to import DeviceEventEmitter. That object is what is required by both methods that weren’t firing for me. There were equally a few disparities between one of the gradle contents and the default one and I hoped those differences were for another native module and not pertaining to this one.

NPM installs v1.2.4 while your comment asks for v1.3.1

Going back to this helped me figure out why I was unable to set dates earlier than current time (add an extra day before converting to milliseconds).

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native alarm Notification not working when we close the ...
when i set the alarm its working when app is open when i schedule the alarm and close the app its not working....
Read more >
android alarm manager error with react native >= 0.68 #445
Hello,. Notification scheduled using the alarm manager does not work anymore since react native version 0.68, was working fine on 0.66.
Read more >
Native Alarm Clock interrupted by push no… - Apple Community
Question: Q: Native Alarm Clock interrupted by push notifications. I have an iPhone 3 GS with the latest ( as of 3/1/2011 )...
Read more >
react-native-alarm-notification - npm
Start using react-native-alarm-notification in your project by running `npm i react-native-alarm-notification`. There are no other projects ...
Read more >
react-native-alarm-notification - npm package - Snyk
The npm package react-native-alarm-notification was scanned for known vulnerabilities and missing license, and no issues were found. Thus the ...
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