Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

358
Visualizações
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>
  
  );
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda