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

[TypeError: Cannot read property 'start' of null] Did anyone got this for the first time? #243

Open
abdulwahid211 opened this issue Oct 2, 2024 · 3 comments

Comments

@abdulwahid211
Copy link

I'm using the latest "react-native-background-actions": "^4.0.1", trying to understand why am I getting null when I do await BackgroundService.start(veryIntensiveTask, options); So did anyone experience this issue before? Please see package.json and sample code which I used


Package.json

{
  "name": "trackingproject",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@dangttp/react-native-background-service": "^0.1.3",
    "@microsoft/signalr": "^8.0.0",
    "@react-native-async-storage/async-storage": "1.23.01",
    "@react-native-community/geolocation": "^3.2.1",
    "@react-native-community/hooks": "^3.0.0",
    "@react-navigation/native": "^6.1.18",
    "@react-navigation/native-stack": "^6.9.17",
    "axios": "^1.6.7",
    "expo": "~51.0.31",
    "expo-camera": "~15.0.15",
    "expo-file-system": "~17.0.1",
    "expo-location": "^17.0.1",
    "expo-sharing": "^12.0.1",
    "expo-status-bar": "~1.12.1",
    "expo-task-manager": "~11.8.2",
    "expo-updates": "~0.25.24",
    "haversine-distance": "^1.2.3",
    "moment": "^2.30.1",
    "node-signalr": "^3.0.0-alpha.1",
    "react": "18.2.0",
    "react-native": "0.74.5",
    "react-native-background-actions": "^4.0.1",
    "react-native-bouncy-checkbox": "^3.0.7",
    "react-native-get-random-values": "~1.11.0",
    "react-native-maps": "1.18.0",
    "react-native-maps-directions": "^1.9.0",
    "react-native-maps-routes": "^1.0.3",
    "react-native-modal": "^13.0.1",
    "react-native-pager-view": "6.3.0",
    "react-native-reanimated": "^3.15.4",
    "react-native-tab-view": "^3.5.2",
    "react-native-url-polyfill": "^2.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.24.0",
    "@tsconfig/react-native": "^3.0.2",
    "@types/jest": "^29.5.11",
    "@types/react": "~18.2.79",
    "@types/react-native": "^0.73.0",
    "@types/react-test-renderer": "^18.0.7",
    "typescript": "^5.3.3"
  },
  "private": true
}

sampleCode.tsx

import * as React from 'react';
import { Text, View} from 'react-native';
import BackgroundService from 'react-native-background-actions';
import { useEffect } from 'react';

const veryIntensiveTask = async (taskDataArguments: any) => {
  console.log('Yahhhhhhhhhhhhhh');
};

const options = {
  taskName: 'Example',
  taskTitle: 'ExampleTask title',
  taskDesc: 'ExampleTask description',
  taskIcon: {
    name: 'ic_launcher',
    type: 'mipmap',
  },
  color: '#ff00ff',
  linkingURI: 'yourSchemeHere://chat/jane', // See Deep Linking for more info
  parameters: {
    delay: 1000,
  },
};

export function IntroScreen({ navigation }: any) {
  const startBackgroundTasks = async () => {
    try {
      if (BackgroundService) {
        await BackgroundService.start(veryIntensiveTask, options); // I believe here where its failing 
        await BackgroundService.updateNotification({
          taskDesc: 'New ExampleTask description',
        });
      }
    } catch (error) {
      console.error(error);
    }
  };

  useEffect(() => {
    console.log('Yaaag');
    startBackgroundTasks();
  }, []);

  return (
    <View>
      <Text>Bavckground Service System</Text>
    </View>
  );
}

Any suggestions or feedback would be appreciated :)

@abdulwahid211 abdulwahid211 changed the title [TypeError: Cannot read property 'start' of null] [TypeError: Cannot read property 'start' of null] Did anyone getting this for the first time? Oct 3, 2024
@abdulwahid211 abdulwahid211 changed the title [TypeError: Cannot read property 'start' of null] Did anyone getting this for the first time? [TypeError: Cannot read property 'start' of null] Did anyone got this for the first time? Oct 3, 2024
@henryobiaraije
Copy link

Any fix for this?

@abdulwahid211
Copy link
Author

Nope still waiting..

@Renato1478
Copy link

I got the same error. I just runned gradlew clean inside android folder and reinstalled the 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

3 participants