Problem unregistering background fetch task

Hi all,

I’m using SDK 34 and when I try to unregister the background fetch task in either Android or iOS I get an error -

await BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK);

Invalid task consumer. Cannot unregister task with name 'background-fetch' because it is associated with different consumer class.

Has anyone see this before? It basically means that the background fetch tasks aren’t getting unregistered.

thanks
Nick

Anyone?

Observing the exact same behaviour

Invalid task consumer. Cannot unregister task with name 'location-updates' because it is associated with different consumer class.

My code looks like this

let isRegistered = await TaskManager.isTaskRegisteredAsync(LOCATION_UPDATES_TASK);
if (isRegistered) {
      await BackgroundFetch.unregisterTaskAsync(LOCATION_UPDATES_TASK);
}

Which to me looks fine. However the error is unexpected.

SDK = 34.0.3

Hi @bosuntechnology and @eddyoc

Someone (not sure if this is you, @bosuntechnology) posted a comment on an issue on GitHub with the same error:

NickR49 commented 6 days ago

Hi all,

What I’m finding is that I must have the await Location.startLocationUpdatesAsync(BACKGROUND_FETCH_TASK); code to make background fetch work for iOS. However when I use that then unregistering the task fails with Invalid task consumer. Cannot unregister task with name 'background-fetch' because it is associated with different consumer class. . I’m guessing this is because the task started as a backgroundFetch task type and got changed to a location task type.

Any idea why calling Location.startLocationUpdatesAsync(taskName) is necessary to get background fetch working for iOS @tsapeta ?

cheers
Nick

Can one of you create a snack that demonstrates the problem and then create an issue here explaining the problem with a link to the snack?

Then post the link to the issue in this thread.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.