• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

239
Vistas
react-native expo error: Unhandled promise rejection: TypeError: null is not an object (evaluating 'RNAlarmNotification.scheduleAlarm')

I'm trying to use a notification package (react-native-alarm-notification) in my React Native project, but am running into some issues. After installing, trying to run scheduleAlarm() results in the following error:

[Unhandled promise rejection: TypeError: null is not an object (evaluating  'RNAlarmNotification.scheduleAlarm')].

I'm not entirely certain what the issue is, as the 'required' parameters of scheduleAlarm are filled and I am uncertain as to what null object is throwing an error. Attempting to fill every possible parameter in scheduleAlarm still returns with null, as does giving only an alarm date and assuming default values are assigned. Tracing the error location however shows the error coming from the regenerator-runtime and react-native modules that came from the default React project build, not from the notification package.

Does anyone have a solution to the problem? 

Function.js:

import { StatusBar } from 'expo-status-bar';
import React, {useState} from 'react';
import { StyleSheet, Text, View, TextInput, Button } from 'react-native';

import ReactNativeAN from 'react-native-alarm-notification';


export default function ShowTasks() {

  async function alarmTest(){
    console.log("Alarm test start");

    const fireDate = ReactNativeAN.parseDate(new Date(Date.now() + 10000));
    
    const alarmNotifData = {
      title: "My Notification Title",
      message: "My Notification Message",
      channel: "my_channel_id",
      small_icon: "../icon.png",
      scheduleType:"once",

      data: { foo: "bar" },
      fire_date:fireDate,
    };

    const alarm = await ReactNativeAN.scheduleAlarm({...alarmNotifData});

    console.log("Alarm test finish");
  }

  return (
    <View>
      <Button onPress={() => {alarmTest();}} 
        title= 'Click here to test alarm.'>
      </Button>
      <StatusBar style="auto" />
    </View>
  
  );
}
almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Rebuilding the App solved my issue:

npx react-native run-android

For android, the package will be linked automatically on the build. but if it doesn't then You need to link it manually.

Make following changes:

android/app/src/main/java//MainApplication.java

add import com.emekalites.react.alarm.notification.ANPackage; on the imports section
add packages.add(new ANPackage()); in List<ReactPackage> getPackages();

android/app/build.gradle

add implementation project(':react-native-alarm-notification') in the dependencies block

android/settings.gradle

add:

include ':react-native-alarm-notification'
project(':react-native-alarm-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-alarm-notification/android')

Checkout the documentation here

almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda