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

IOS not working #166

Closed
bhanuka96 opened this issue Nov 23, 2020 · 13 comments
Closed

IOS not working #166

bhanuka96 opened this issue Nov 23, 2020 · 13 comments

Comments

@bhanuka96
Copy link

bhanuka96 commented Nov 23, 2020

Android is working fine. ios not working. Is it possible to fix it or do you guys working on it.

Error - This error is coming every second

2020-11-23 17:42:50.137980+0530 Runner[385:8446] [VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
2020-11-23 17:42:57.035117+0530 Runner[385:8176] LOCATION UPDATE FAILURE:Error reason: (null)Error description: The operation couldn’t be completed. (kCLErrorDomain error 1.)
2020-11-23 17:42:57.812553+0530 Runner[385:8176] LOCATION UPDATE FAILURE:Error reason: (null)Error description: The operation couldn’t be completed. (kCLErrorDomain error 1.)

Service class

class BackgroundLocationService {
  static const String _isolateName = "LocatorIsolate";
  ReceivePort port = ReceivePort();

  Future<void> initPlatformState() async {
    await BackgroundLocator.initialize();
  }

  void registerPort() {
    IsolateNameServer.registerPortWithName(port.sendPort, LocationServiceRepository.isolateName);
  }

  static void callback(LocationDto locationDto) async {
    final SendPort send = IsolateNameServer.lookupPortByName(_isolateName);
    send?.send(locationDto);
  }

  void startLocationService() {
    Map<String, dynamic> data = {'countInit': 1};
    BackgroundLocator.registerLocationUpdate(LocationCallbackHandler.callback,
        initCallback: LocationCallbackHandler.initCallback,
        initDataCallback: data,
        disposeCallback: LocationCallbackHandler.disposeCallback,
        autoStop: false,
        iosSettings: IOSSettings(accuracy: LocationAccuracy.HIGH, distanceFilter: 0),
        androidSettings: AndroidSettings(accuracy: LocationAccuracy.HIGH, interval: 5, distanceFilter: 0));
  }

  void stopLocationService(){
    BackgroundLocator.unRegisterLocationUpdate();
  }

  ReceivePort getData() {
    return port;
  }
}

on InitState

  @override
  void initState() {
    super.initState();
    _bls.registerPort();
    _bls.initPlatformState().then((value) {
      locationSubscription = _bls.port.listen(backgroundLocPort);
    });

Start Service on Inactive mode

 case AppLifecycleState.inactive:
            _bls.startLocationService();

Other functions and methods are the same as example

Flutter doctor

Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale en-LK)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
@mehdok
Copy link
Collaborator

mehdok commented Nov 23, 2020

HI @bhanuka96

Thank you for opening an issue;

Please share some code;

@bhanuka96
Copy link
Author

HI @bhanuka96

Thank you for opening an issue;

Please share some code;

@mehdok please check now

@mehdok
Copy link
Collaborator

mehdok commented Nov 23, 2020

Good, as far as I can see there is nothing wrong with the code;
Please answer these questions:

  1. Did you did the setup process for iOS?
  2. Did you give him the right permission?
  3. Are you running on real device or simulator?
  4. Is the example app is running fine for you?
  5. Do you get any error beside the one you specified? anything could help. (please run the app with Xcode to see extra logs)

@bhanuka96
Copy link
Author

  1. yes, I follow this https://github.com/rekab-app/background_locator/wiki/Setup

  2. added above permissions to my app

  3. real Device (iPhone xs)

4)example app cannot open in Xcode

  1. I got the below error on the console after minimizing the app
2020-11-23 17:42:50.137980+0530 Runner[385:8446] [VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
2020-11-23 17:42:57.035117+0530 Runner[385:8176] LOCATION UPDATE FAILURE:Error reason: (null)Error description: The operation couldn’t be completed. (kCLErrorDomain error 1.)
2020-11-23 17:42:57.812553+0530 Runner[385:8176] LOCATION UPDATE FAILURE:Error reason: (null)Error description: The operation couldn’t be completed. (kCLErrorDomain error 1.)
...it's not stop

@bhanuka96
Copy link
Author

@mehdok Do you have any solution for this issue?

@mehdok
Copy link
Collaborator

mehdok commented Nov 24, 2020

There is not any straight solution with this kind of problems, I just can suggest thing to narrow down the problem and may be finally we can find something for the problem.

I got the below error on the console after minimizing the app

  • Did you gave always permission? app won't work in background if you give it whenInUse permission;
  • Please try to run your app on the simulator to see if the problem still exist;
  • Please run the example app to see if you are having the same problem or not;

@bhanuka96
Copy link
Author

@mehdok Okay I will try and let you know. btw example app is not open on xcode. I think some files are mission in example/ios

@mehdok
Copy link
Collaborator

mehdok commented Nov 24, 2020

Can you tell me the exact error you are getting when trying to open example app?

@bhanuka96
Copy link
Author

@bhanuka96
Copy link
Author

bhanuka96 commented Nov 24, 2020

Previously, I start service in inactive state.


 case AppLifecycleState.inactive:
        { _bls.startLocationService();

That's the problem. I just start service onTap event. now it's working fine.

Did you have time to check example video? What is the problem? I decided to use this plugin on our production app. Is it okay? BTW our app is a fully GPS-based application, previously we use geolocator plugin. this plugin not working on the background.

@mehdok
Copy link
Collaborator

mehdok commented Nov 26, 2020

Sorry for the delay, Yes I checked the video, but the video without any logs is useless;
About you production app, we use it in our app, REKAB, without any problem. But it is an open source plugin without any warrantee or support, so use it at your own risk;

case AppLifecycleState.inactive:
{ _bls.startLocationService();

And if this was your problem and it is fixed, please close the issue;

@bhanuka96
Copy link
Author

@mehdok Thanks for the reply. We decided to use your plugin for our taxi app(driver app).

@mehdok
Copy link
Collaborator

mehdok commented Nov 26, 2020

Hope it works for you, Please reach out if you had any other problem.

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