TypeError: null is not an object (evaluating 'ForegroundServiceModule.createNotificationChannel')

533 Views Asked by At

I am using https://github.com/voximplant/react-native-foreground-service library for running foreground tasks.

const channelConfig = {
    id: 'channelId',
    name: 'Channel name',
    description: 'Channel description',
    enableVibration: false
};
VIForegroundService.createNotificationChannel(channelConfig);

when Im running this part of code which I got from documentation, happens error and I dont know why? Did you met this issue?

1

There are 1 best solutions below

0
On

This answer is quite late but I hope it will help people in the future,

I was getting:

Unhandled Promise Rejection (id: 0): TypeError: null is not an object (evaluating 'ForegroundServiceModule.createNotificationChannel')

But after adding:

import ReactNativeForegroundService from '@supersami/rn-foreground-service'; ReactNativeForegroundService.register(); AppRegistry.registerComponent(appName, () => App);

Into my index.js, The Foreground service was working.

*Replace The import in the code above with the service you are using.