emekalites / react-native-alarm-notification

schedule alarm and local notification in react-native
https://www.npmjs.com/package/react-native-alarm-notification
MIT License
225 stars 95 forks source link

I got an error when I install the appDebug React-Native. The error was : cannot find symbol in AlarmDismissReceiver.java #87

Closed ayubmm closed 4 years ago

ayubmm commented 4 years ago

Task :react-native-alarm-notification:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings 21 actionable tasks: 21 executed /home/ayub/Documents/Project React Native/todoList/node_modules/react-native-alarm-notification/android/src/main/java/com/emekalites/react/alarm/notification/AlarmDismissReceiver.java:25: error: cannot find symbol alarmUtil.stopAlarmSound(); ^ symbol: variable alarmUtil location: class AlarmDismissReceiver 1 error

ayubmm commented 4 years ago

I tried to add AlarmUtil alarmUtil = new AlarmUtil((Application) context.getApplicationContext()); and change the code from :

try {
        AlarmUtil alarmUtil = new AlarmUtil((Application) context.getApplicationContext());

        if (ANModule.getReactAppContext() != null) {
            int notificationId = intent.getExtras().getInt(Constants.DISMISSED_NOTIFICATION_ID);
            ANModule.getReactAppContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("OnNotificationDismissed", "{\"id\": \"" + notificationId + "\"}");

            alarmUtil.removeFiredNotification(notificationId);

            alarmUtil.doCancelAlarm(notificationId);
        }
    } catch (Exception e) {
        alarmUtil.stopAlarmSound();
        System.err.println("Exception when handling notification dismiss. " + e);
    }

to :

try {
        AlarmUtil alarmUtil = new AlarmUtil((Application) context.getApplicationContext());

        if (ANModule.getReactAppContext() != null) {
            int notificationId = intent.getExtras().getInt(Constants.DISMISSED_NOTIFICATION_ID);
            ANModule.getReactAppContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("OnNotificationDismissed", "{\"id\": \"" + notificationId + "\"}");

            alarmUtil.removeFiredNotification(notificationId);

            alarmUtil.doCancelAlarm(notificationId);
        }
    } catch (Exception e) {
        AlarmUtil alarmUtil = new AlarmUtil((Application) context.getApplicationContext());

        alarmUtil.stopAlarmSound();
        System.err.println("Exception when handling notification dismiss. " + e);
    }

I was just messing around because I haven't learned java. but now the appdebug is installed. Is this a solution? is there anyone facing the same problem ?

serinuntius commented 4 years ago

I have the same problem.

I think this pr is related.

https://github.com/emekalites/react-native-alarm-notification/pull/85

mohammadsolgi commented 4 years ago

I have the same problem. anyone can help us?

ayubmm commented 4 years ago

I have the same problem. anyone can help us?

Try to change it like I did in this comment :

I tried to add AlarmUtil alarmUtil = new AlarmUtil((Application) context.getApplicationContext()); and change the code from :

`try { AlarmUtil alarmUtil = new AlarmUtil((Application) context.getApplicationContext());

        if (ANModule.getReactAppContext() != null) {
            int notificationId = intent.getExtras().getInt(Constants.DISMISSED_NOTIFICATION_ID);
            ANModule.getReactAppContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("OnNotificationDismissed", "{\"id\": \"" + notificationId + "\"}");

            alarmUtil.removeFiredNotification(notificationId);

            alarmUtil.doCancelAlarm(notificationId);
        }
    } catch (Exception e) {
        alarmUtil.stopAlarmSound();
        System.err.println("Exception when handling notification dismiss. " + e);
    }`

to :

`try { AlarmUtil alarmUtil = new AlarmUtil((Application) context.getApplicationContext());

        if (ANModule.getReactAppContext() != null) {
            int notificationId = intent.getExtras().getInt(Constants.DISMISSED_NOTIFICATION_ID);
            ANModule.getReactAppContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("OnNotificationDismissed", "{\"id\": \"" + notificationId + "\"}");

            alarmUtil.removeFiredNotification(notificationId);

            alarmUtil.doCancelAlarm(notificationId);
        }
    } catch (Exception e) {
        AlarmUtil alarmUtil = new AlarmUtil((Application) context.getApplicationContext());

        alarmUtil.stopAlarmSound();
        System.err.println("Exception when handling notification dismiss. " + e);
    }`

I was just messing around because I haven't learned java. but now the appdebug is installed. Is this a solution? is there anyone facing the same problem ?

vincevannoort commented 4 years ago

Feel free to make the changes made in this commit and open a pull request:

https://github.com/vincevannoort/react-native-alarm-notification/tree/a963aec83b7d875df8eff34481690af6c15e3c18

Upon accidant i made more commits to my personal project, however, the above fixes the issue.

maretana commented 4 years ago

I submitted a PR to fix the compilation problem https://github.com/emekalites/react-native-alarm-notification/pull/90

emekalites commented 4 years ago

v1.7.1 takes care of this, thanks guys.