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

crashes in production for android apps #2166

Open
NadeemKhanFh opened this issue Oct 9, 2024 · 2 comments
Open

crashes in production for android apps #2166

NadeemKhanFh opened this issue Oct 9, 2024 · 2 comments

Comments

@NadeemKhanFh
Copy link

NadeemKhanFh commented Oct 9, 2024

Your Environment

  • Plugin version: ^4.17.1
  • Platform: Android
  • OS version: android 9,
  • Device manufacturer / model:Tecno Spark 4
  • React Native version (react-native -v): "^0.74.5",
  • Plugin config
React.useEffect(() => {
    /// 1.  Subscribe to events.
    const onLocation: Subscription = BackgroundGeolocation.onLocation(
      (location) => {
        // console.log('[onLocation]', location);

        setLocationData({
          lat: location?.coords?.latitude,
          long: location?.coords?.longitude,
        });

        setIs_moving(location?.is_moving);
      }
    );

    const onMotionChange: Subscription = BackgroundGeolocation.onMotionChange(
      (event) => {
        // console.log('[onMotionChange]', event);
      }
    );

    const onActivityChange: Subscription =
      BackgroundGeolocation.onActivityChange((event) => {
        //  console.log('[onActivityChange]', event);
      });

    const onProviderChange: Subscription =
      BackgroundGeolocation.onProviderChange((event) => {
        // console.log('[onProviderChange]', event);
      });

    const onHttp = BackgroundGeolocation.onHttp((httpEvent) => {
      //console.log('[http] ', httpEvent);
    });

    const onAuthorization = BackgroundGeolocation.onAuthorization(
      (httpEvent) => {
        //  console.log('[onAuthorization] ', httpEvent);
      }
    );

    /// 2. ready the plugin.
    BackgroundGeolocation.ready({
      locationAuthorizationRequest: 'Always',
      disableLocationAuthorizationAlert: false,
      backgroundPermissionRationale: {
        title:
          "Allow Cheezious to access this device's location in the background?",
        message:
          'In order to track your activity in the background, please enable your backgoround location permission',
        positiveAction: 'Allow',
        negativeAction: 'Cancel',
      },
      notification: {
        title: 'Background Location Tracking',
        text: 'We are tracking your location to provide real-time updates.',
      },
      // Geolocation Config
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: 100,
      // Activity Recognition
      stopTimeout: 5,
      // Application config
      debug: false, // <-- enable this hear sounds for background-geolocation life-cycle.
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
      startOnBoot: true, // <-- Auto start tracking when device is powered-up.
      // HTTP / SQLite config
      batchSync: false, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
      autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
      enableHeadless: true,
      url: `${Config.API_URL}riders/update/location`,
      method: 'POST',

      headers: {
        authorization: 'Bearer ' + token ?? '',
      },
    })
      .then((state) => {
        console.log(
          '- BackgroundGeolocation is configured and ready: ',
          state.enabled
        );
        if (!state.enabled) {
          BackgroundGeolocation.start();
        }
      })
      .catch((error) => {
        console.log('- BackgroundGeolocation error: ', error);

        if (error === 'Permission denied') {
          setShowLocationModal(true);
        }
      });

    return () => {
      // Remove BackgroundGeolocation event-subscribers when the View is removed or refreshed
      // during development live-reload.  Without this, event-listeners will accumulate with
      // each refresh during live-reload.
      onLocation.remove();
      onMotionChange.remove();
      onActivityChange.remove();
      onProviderChange.remove();
      onHttp.remove();
      onAuthorization.remove();
    };
  }, []);

Expected Behavior

It should not crash in production

Actual Behavior

It should not crash in production

Steps to Reproduce

its happening in production, i am sending screenshots
1.
2.
3.
4.

Context

Debug logs

Logs
PASTE_YOUR_LOGS_HERE
Screenshot 2024-10-09 at 3 04 38 PM Screenshot 2024-10-09 at 3 05 48 PM
@NadeemKhanFh
Copy link
Author

@christocracy ?? can you please comment on this?

@christocracy
Copy link
Member

Have you tried searching the issues for that error?

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

2 participants