No notification and no native alarm
See original GitHub issueI’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:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
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
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).