flutter-geolocator
flutter-geolocator copied to clipboard
[Question]: getCurrentPosition not working on iOS Testflight
Please check the following before submitting a new issue.
- [X] I have searched the existing issues.
- [X] I have carefully read the documentation.
Please select for which platform(s) you need help
- [ ] Android
- [X] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows
Your question
Hi,
I have a problem after uploading to TestFlight.
Popup permission shown, already granted.
But it is stuck at getCurrentPosition never returns.
Android:
- Real device ✅
iOS:
- Debug with Simulator ✅
- Debug with Real Device ✅
- TestFlight ⛔️
Added these to Info.plist
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
// geolocation.dart
import 'package:geolocator/geolocator.dart';
/// Determine the current position of the device.
///
/// When the location services are not enabled or permissions
/// are denied the `Future` will return an error.
Future<Position> getMyLocation() async {
bool serviceEnabled;
LocationPermission permission;
// Test if location services are enabled.
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
// Location services are not enabled don't continue
// accessing the position and request users of the
// App to enable the location services.
await Geolocator.openLocationSettings();
return Future.error('Location services are disabled.');
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
// Permissions are denied, next time you could try
// requesting permissions again (this is also where
// Android's shouldShowRequestPermissionRationale
// returned true. According to Android guidelines
// your App should show an explanatory UI now.
return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
// Permissions are denied forever, handle appropriately.
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
// When we reach here, permissions are granted and we can
// continue accessing the position of the device.
final pos = await Geolocator.getCurrentPosition(
timeLimit: const Duration(minutes: 1),
forceAndroidLocationManager: false,
);
return pos;
}
XCode: 15.3 Flutter: 3.22.1 Geolocator: 12.0.0 Device: iOS 17.4.1
Thanks 🙏🏻
Version
12.0.0
Dear @ariefsn,
Is the TestFlight build installed on the same device as the "Real" de device build? And can you remove the installed version entirely on the device before installing the "TestFlight build"? And can you test your app on a local device running in "Release" flutter run --release mode? For any possible changes?
Kind regards,
Tim
Dear @ariefsn,
Is the TestFlight build installed on the same device as the "Real" de device build? And can you remove the installed version entirely on the device before installing the "TestFlight build"? And can you test your app on a local device running in "Release"
flutter run --releasemode? For any possible changes?Kind regards,
Tim
Yes, it's the same device. Already did that, remove first, then re-install from TestFlight, still same. Run release mode working fine 🙁
Hi We have the same problem here, when the location of the simulator is set to none, the splash screen keeps freezing. When I set the location to custom location it continues. With my test I have found that the code stops after getCurrentPosition() when Location is set to None (it doens't return anything and just wait). It is not possible to grab in catch.
use TimeLimit 5 seconds
Dear @ramaces,
Thanks for you input could you file a separate issue? Locations testing on simulators could lead to strange behaviour. It is advised to test on a real device.
Kind regards,
Tim
Same issue Have you fixed it yet? @ariefsn
Same issue
Have you fixed it yet? @ariefsn
Yea it's fixed, but I don't know which step that resolved that 🫣 Here are steps that I tried, you can try.
- Upgrade flutter to latest
- Clear XCode cache
- Clean and reinstall deps
- Rebuild and reupload to Testflight
Same issue Have you fixed it yet? @ariefsn
Yea it's fixed, but I don't know which step that resolved that 🫣 Here are steps that I tried, you can try.
- Upgrade flutter to latest
- Clear XCode cache
- Clean and reinstall deps
- Rebuild and reupload to Testflight
Can u share code for me
use timeout and it will be work on simulator also
It looks like this issue has been resolved.
I'll close this issue for now. Feel free to reopen or file a new issue with additional information.
Kind regards,