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

Start up and run IOS crash #565

Closed
KongGeJian opened this issue Apr 1, 2019 · 5 comments · Fixed by HaylLtd/cordova-background-geolocation-plugin#20 · May be fixed by #633
Closed

Start up and run IOS crash #565

KongGeJian opened this issue Apr 1, 2019 · 5 comments · Fixed by HaylLtd/cordova-background-geolocation-plugin#20 · May be fixed by #633
Labels
stale auto labeled abandoned issues after a period of inactivity

Comments

@KongGeJian
Copy link

Your Environment

  • Plugin version:3.0.3
  • Platform: iOS
  • OS version:12.1
  • Device manufacturer and model: iPhone 6s plus
  • Running in Simulator: Yes
  • Cordova version (cordova -v): 9.0.0
  • Cordova platform version (cordova platform ls):5.0.0
  • Plugin configuration options:
  • Link to your project:

Context

  this.platform.ready().then(() => {
    this.init();
  });
  // init bg-geo
  init() {
    const config: BackgroundGeolocationConfig = {
      desiredAccuracy: 10,
      stationaryRadius: 1, 
      distanceFilter: 1,
      maxLocations: 10,
      debug: true,
      stopOnTerminate: false
    };
    this.backgroundGeolocation.configure(config)
      .then(() => {
        this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location) => {
           this.logger.info(location);
        });
      });
    this.backgroundGeolocation.start();
 }

Expected Behavior

App runs normally, running location monitoring

Actual Behavior

After init background-geolocation,this is run 'start()'. App crash.

2019-04-01 10:16:32.585834+0800 TimeStory[6768:1623947] CDVBackgroundGeolocation #start
2019-04-01 10:16:32.586395+0800 TimeStory[6768:1624020] BgGeo #start: 0
2019-04-01 10:16:32:586 TimeStory[6768:1624018] BgGeo #start: 0
2019-04-01 10:16:32:589 TimeStory[6768:1623947] DistanceFilterLocationProvider iOS9 detected
2019-04-01 10:16:32.604441+0800 TimeStory[6768:1624020] DistanceFilterLocationProvider will start
2019-04-01 10:16:32:589 TimeStory[6768:1623947] DistanceFilterLocationProvider will start
2019-04-01 10:16:32.612263+0800 TimeStory[6768:1623947] CDVBackgroundGeolocation #onAuthorizationChanged
2019-04-01 10:16:32.612993+0800 TimeStory[6768:1624020] DistanceFilterLocationProvider switchMode 1
2019-04-01 10:16:32:592 TimeStory[6768:1623947] DistanceFilterLocationProvider switchMode 1
2019-04-01 10:16:32.630591+0800 TimeStory[6768:1624021] LocationManager didChangeAuthorizationStatus 4
2019-04-01 10:16:32:609 TimeStory[6768:1623947] LocationManager didChangeAuthorizationStatus 4
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.

Possible Fix

Recursive callbacks occur here, and the comments run correctly.

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
    if (prevNotificationDelegate && [prevNotificationDelegate respondsToSelector:@selector(userNotificationCenter:willPresentNotification:withCompletionHandler:)])
    {
        // Give other delegates (like FCM) the chance to process this notification
//        [prevNotificationDelegate userNotificationCenter:center willPresentNotification:notification withCompletionHandler:^(UNNotificationPresentationOptions options) {
//            completionHandler(UNNotificationPresentationOptionAlert);
//        }];
    }
    else
    {
        completionHandler(UNNotificationPresentationOptionAlert);
    }
}

Steps to Reproduce

Context

Debug logs

@JaimeHere
Copy link

This same issue happened to me.

I solved installing the plugin cordova-plugin-local-notification.

On iOS Devices a notification is triggered when the location is updated. It seems you need to have a way to show it or the app will crash.

@KongGeJian
Copy link
Author

This same issue happened to me.

I solved installing the plugin cordova-plugin-local-notification.

On iOS Devices a notification is triggered when the location is updated. It seems you need to have a way to show it or the app will crash.

First of all, thank you for your answer.

1.Since call notifications require plugin cordova-plugin-local-notification. howerer the NPM documentation is independent.
2.If no notification plugin is found. Why is there a dead cycle?
3.I comment out the code. App works normally, And notification bar pop-up notice

Don't know why the author designed it. ha-ha

dr-itz added a commit to dr-itz/cordova-plugin-background-geolocation that referenced this issue Sep 30, 2019
At the beginning of `onFinishLaunching`, `center.delegate` is set to
`self`. Later on, when debugging is enabled, the current value of
`center.delegate` is saved info `prevNotificationDelegate`. Since this
has already been set to `self`, a recursion and later a stack overflow
happens.

The commit that added the code
  80be0fd ("iOS avoid taking control of UNUserNotificationCenter", 2018-08-20)
has not removed the block at the beginning, but the original one referenced
there did:
  https://github.com/mauron85/react-native-background-geolocation/pull/268/files

So that was probably a mis-merge.

Fixes mauron85#565
@stale
Copy link

stale bot commented Oct 13, 2019

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.

@stale stale bot added the stale auto labeled abandoned issues after a period of inactivity label Oct 13, 2019
@stale
Copy link

stale bot commented Oct 20, 2019

This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.

@stale stale bot closed this as completed Oct 20, 2019
@mubashir6258
Copy link

hello everyone, That issue is still alive on IOS and needs to be fixed asap as i just recently implemented background-geolocation and what i noticed is i am still having that app crashing issue on debug=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale auto labeled abandoned issues after a period of inactivity
Projects
None yet
3 participants