Rapsssito / react-native-background-actions

React Native background service library for running background tasks forever in Android & iOS.
MIT License
817 stars 116 forks source link

[ERROR] Cannot read property 'start' of null. #222

Closed aymanMFD closed 4 months ago

aymanMFD commented 5 months ago

When I try to start a service by pressing a button, the warning Cannot read property 'start' of null. pops up.

This is my code

const veryIntensiveTask = async (taskDataArguments) => {
    // Example of an infinite loop task
    console.log("Starting")
    const { delay } = taskDataArguments;
    await new Promise( async (resolve) => {
        for (let i = 0; BackgroundService.isRunning(); i++) {
            console.log(i);
            await sleep(delay);
        }
    });
};

const options = {
    taskName: 'Example',
    taskTitle: 'ExampleTask title',
    taskDesc: 'ExampleTask description',
    taskIcon: {
        name: 'appstore',
        type: 'drawable',
    },
    color: '#ff00ff',
    linkingURI: 'yourSchemeHere://chat/jane', // See Deep Linking for more info
    parameters: {
        delay: 1000,
    },
};
const startBackgroundService = async () => {
        await BackgroundService.start(veryIntensiveTask, options);
        await BackgroundService.updateNotification({taskDesc: "This is the counter"})
    };
// More code
<TouchableOpacity onPress={startBackgroundService}>
    <Text>Start BackgroundService</Text>
</TouchableOpacity>
zju1 commented 5 months ago

The same here

Rapsssito commented 4 months ago

Duplicate of #199