GithubHelp home page GithubHelp logo

Comments (8)

ocetnik avatar ocetnik commented on August 23, 2024

I tried to test it now and everything is working properly in my case. Have you already solved this problem? If not, could you paste here any major piece of code and write on which line the error occurs?

from react-native-background-timer.

ys27 avatar ys27 commented on August 23, 2024

So inside this one component.js, I have set
import BackgroundTimer from 'react-native-background-timer';
Then inside the class, I have these two functions

 _startDailyTimer() {
        BackgroundTimer.stop();
        this._reduceAutoItems();
        //86400000
        BackgroundTimer.start(3000);
        DeviceEventEmitter.addListener('backgroundTimer', () => {
        this._reduceAutoItems();
    });
}
_startOffsetTimer() {
    AsyncStorage.getItem("Timer").then((value) => {
        if (value === null || value === false) {
            let now = new Date();
            let offset = moment().endOf('day')-now;
            BackgroundTimer.start(offset);
            DeviceEventEmitter.addListener('backgroundTimer', () => {
                this._startDailyTimer();
            });
            AsyncStorage.setItem("Timer", true);
        }
        });
}

Thank you.

from react-native-background-timer.

ocetnik avatar ocetnik commented on August 23, 2024

The error is probably caused by adding boolean as the second parameter in AsyncStorage.setItem("Timer", true);
The second parameter (value) must be a string
Check https://facebook.github.io/react-native/docs/asyncstorage.html

from react-native-background-timer.

ys27 avatar ys27 commented on August 23, 2024

I've changed the values into a string but the error persists.

from react-native-background-timer.

ys27 avatar ys27 commented on August 23, 2024

Is it okay for there to be multiple instances of backgroundtimer? How does the string backgroundTimer as the first param in

DeviceEventEmitter.addListener('backgroundTimer', () => {
    this._reduceAutoItems();
});

relate to anything?

from react-native-background-timer.

IjzerenHein avatar IjzerenHein commented on August 23, 2024

Did you link the library using react-native link react-native-background-timer ?

from react-native-background-timer.

ys27 avatar ys27 commented on August 23, 2024

Yes, I have. Since then I have resorted to using modules to communicate with the android native components. Should I close this thread?

from react-native-background-timer.

ocetnik avatar ocetnik commented on August 23, 2024

If everything is OK, you can.

from react-native-background-timer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.