Closed jabguru closed 8 months ago
I had a similar issue with the notificationTapCallback
argument. I had to add the @pragma("vm:entry-point")
decorator. Can you send the full code for the registerLocationUpdate
function?
@Myzel394 thanks for your response
registerLocationUpdate is a method in the package.
@Myzel394 thanks for your response
registerLocationUpdate is a method in the package.
I mean your code :D Can you send your code / how do you call this function?
@Myzel394 that's what is in the first image, or should I resend the whole thing?
@Myzel394 that's what is in the first image, or should I resend the whole thing?
yes please, just paste the content itself
Future<void> startLocationService() async {
if (accountService.userCheck(userType: UserType.courier) &&
currentScreenService.locationChangeLocationService == null) {
//? calling this to get permission
await locationService.getUserLocation();
// TODO: THERE'S AN ERROR HERE
await BackgroundLocator.registerLocationUpdate(
updateLocationCallback,
autoStop: false,
iosSettings: const IOSSettings(
accuracy: LocationAccuracy.NAVIGATION,
distanceFilter: 200,
),
androidSettings: AndroidSettings(
accuracy: LocationAccuracy.NAVIGATION,
interval: 5,
distanceFilter: 200,
androidNotificationSettings: AndroidNotificationSettings(
notificationChannelName: 'Location tracking',
notificationTitle: 'bg_location_notif_title'.tr(),
notificationMsg: 'bg_location_notif_msg'.tr(),
notificationBigMsg: 'bg_location_notif_big_msg'.tr(),
notificationIconColor: kColorScheme.primaryColor,
notificationIcon: 'notif_icon',
),
),
);
}
}
@Myzel394
What does your updateLocationCallback
look like?
Future<void> updateLocationCallback(LocationDto locationDto) async {
await setupLocator(fromIsolate: true);
if (accountService.userCheck(userType: UserType.courier) &&
currentScreenService.locationChangeLocationService == null) {
try {
double lat = locationDto.latitude;
double lng = locationDto.longitude;
if (accountService.loggedInUser!.courier!.currentPositionLatitude !=
lat ||
accountService.loggedInUser!.courier!.currentPositionLongitude !=
lng) {
Map data = {
'current_position_latitude': lat.toString(),
'current_position_longitude': lng.toString(),
};
await accountRepository.updateCourier(data);
log('Courier location updated: $lat, $lng');
} else {
log('Courier\'s position didn\'t change: $lat, $lng');
}
} catch (e) {
log('Error updating courier location: $e');
}
}
}
@Myzel394
So I should just add the decorator @pragma("vm:entry-point") To the function?
@Myzel394
@jabguru yes exactly, sorry, I thought I wrote you an answer already but seems like I forgot to actually send the comment xD
@jabguru @Myzel394 whats the answer again? im blank here
@santojc its to add @pragma("vm:entry-point") ontop of your callback method.
I didn't have to do right now though, it's working on it's own again.
I'll be closing the issue, it's working again.
@santojc it's exactly what @santojc said; it worked for me back then, but I don't know whether it will work now
I get this error on both Android and iOS