transistorsoft / react-native-background-fetch

Periodic callbacks in the background for both IOS and Android
MIT License
1.49k stars 193 forks source link

working example after kill app #273

Closed roei133 closed 4 years ago

roei133 commented 4 years ago

Expected Behavior

The app should work after the app is kill or terminated or reboot and thats what i want ,

Actual Behavior

its work only on background :(

this is my example :


import BackgroundFetch from 'react-native-background-fetch';
import React, {Component} from 'react';
import {Text} from 'react-native';
import moment from 'moment';

export default class App extends Component {
  componentDidMount() {
    // Configure it.
    BackgroundFetch.configure(
      {
        minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed)
        // Android options
        forceAlarmManager: false, // <-- Set true to bypass JobScheduler.
        stopOnTerminate: false,
        startOnBoot: true,
        requiredNetworkType: BackgroundFetch.NETWORK_TYPE_NONE, // Default
        requiresCharging: false, // Default
        requiresDeviceIdle: false, // Default
        requiresBatteryNotLow: false, // Default
        requiresStorageNotLow: false, // Default
      },
      async taskId => {
        console.log(
          ' background-fetch event works!',
          moment().format('MMMM Do YYYY, h:mm:ss a'),
          taskId,
        );
        // Required: Signal completion of your task to native code
        // If you fail to do this, the OS can terminate your app
        // or assign battery-blame for consuming too much background-time
        BackgroundFetch.finish(taskId);
      },
      error => {
        console.log('[js] RNBackgroundFetch failed to start');
      },
    );

    // Optional: Query the authorization status.
    BackgroundFetch.status(status => {
      switch (status) {
        case BackgroundFetch.STATUS_RESTRICTED:
          console.log('BackgroundFetch restricted');
          break;
        case BackgroundFetch.STATUS_DENIED:
          console.log('BackgroundFetch denied');
          break;
        case BackgroundFetch.STATUS_AVAILABLE:
          console.log('BackgroundFetch is enabled');
          break;
      }
    });
  }
  render() {
    return <Text>Hello roei</Text>;
  }
}
christocracy commented 4 years ago

I suggest you try the /example in this repo.

roei133 commented 4 years ago

@christocracy Do you have Facebook or something else that i could talk with you to make it more correctly and make it works .

christocracy commented 4 years ago

Have you tried the /example in this repo.

Sorry, chat is not possible.

roei133 commented 4 years ago

I di tried it yes but its working only in background and not when the app is terminated or kill. It will help me if u send me snack.io of expo ..something that i will copy into my new project and it will work after i will kill the app. When i try to clone your example so it not run and gives errors..so i open new project and just copy your app.js into my . But as i said it didnt work.

בתאריך יום ה׳, 4 ביוני 2020, 13:51, מאת Chris Scott ‏< notifications@github.com>:

Have you tried the /example in this repo.

Sorry, chat is not possible.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/transistorsoft/react-native-background-fetch/issues/273#issuecomment-638774623, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTRHTVI4KC7WQNRVEVJ7PTRU54DDANCNFSM4NRUHQGQ .

christocracy commented 4 years ago

http://dontkillmyapp.com

roei133 commented 4 years ago

I want to check with you a few things, as I mentioned before so what I did is I just started a new project in React Native and then pasted your example to app.js. I didn't make any changes beyond that in manifast or gradle (i didnt do anything,only open new project) and didn't interfere with the code, I just copied and run it..Is it okay what I did or do I have to make your example clone for it to work?

בתאריך יום ה׳, 4 ביוני 2020, 15:24, מאת Chris Scott ‏< notifications@github.com>:

http://dontkillmyapp.com

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/transistorsoft/react-native-background-fetch/issues/273#issuecomment-638814492, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTRHTXSDZLXODNBSQQXRELRU6G7VANCNFSM4NRUHQGQ .

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.