Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the supported range of Android version? #201

Open
Barryhuan opened this issue Dec 23, 2022 · 0 comments
Open

What is the supported range of Android version? #201

Barryhuan opened this issue Dec 23, 2022 · 0 comments

Comments

@Barryhuan
Copy link

Barryhuan commented Dec 23, 2022

The Android version of my mobile phone is 12, and the background will not output test content.
I use the simulator to test different versions. This module only supports android 7, that is, API 24-25.
The code is as follows:

package.json

{
  "react": "17.0.1",
  "react-native": "0.64.4",
  "react-native-background-job": "^2.3.1"
}
import { Component } from 'react';
import BackgroundJob from "react-native-background-job";
function getCurrentDate() {
  let date = new Date();
  let year = date.getFullYear();
  let month = date.getMonth() + 1;
  let day = date.getDate();
  let hour = date.getHours();
  let minutes = date.getMinutes();
  let second = date.getSeconds();
  let times = [month, day, hour, minutes, second];
  times.forEach((i, _, arr) => i < 10 && (arr[_] = '0' + i));
  return `${year}-${times[0]}-${times[1]} ${times[2]}:${times[3]}:${times[4]}`;
}

BackgroundJob.register({
  jobKey: 'myJobKey',
  job: () => console.log(`${getCurrentDate()}:Background Job fired!`)
});

class App extends Component {
  componentDidMount() {
    BackgroundJob.schedule({
      jobKey: 'myJobKey',
      exact: true,
      allowWhileIdle: true,
      notificationText :"test",
      notificationTitle :'title'
    })
    .then(() => console.log(`${getCurrentDate()}:Success`))
    .catch(err => console.err(err));
  }
  render() {
    return null;
  }
};

export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant