flutter_workmanager
                                
                                
                                
                                    flutter_workmanager copied to clipboard
                            
                            
                            
                        feature/handle-input-data-background-processing-ios
Based on 0.5.0-dev.8 Actual behavior make inputData always null on iOS background processing. This PR fix that.
What if you have multiple background workers running, won't the input data be overridden for each? Or, inputData from task A is available on task B (which is unintended)
What if you have multiple background workers running, won't the input data be overridden for each? Or, inputData from task A is available on task B (which is unintended)
I do not think so if the uniqueName is different or the work policy is set to ExistingWorkPolicy.append; although, I have yet to test this yet.
@AdamBridges what did you find out? I would be looking for storing input data in a hash table, specific to the supplied uniqueTaskName.
@AdamBridges what did you find out? I would be looking for storing input data in a hash table, specific to the supplied uniqueTaskName.
Pardon the delay: I've been trying to test things out on iOS but I can't escape this error on 0.5.1 before I try this PR:
flutter: PlatformException(unhandledMethod("registerOneOffTask") error, Unhandled method registerOneOffTask, null, null)
flutter: 
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
<asynchronous suspension>
#2      Workmanager.registerOneOffTask (package:workmanager/src/workmanager.dart:192:7)
<asynchronous suspension>
@ened Any ideas what's going on here?
Here's what I'm calling and doing so on a real iphone:
inputData ??= {};
inputData.addAll({
      taskKey : uniqueTaskName,
      tagKey : retryProcessTag
    });
await Workmanager().registerOneOffTask(
        "task-identifier",
        "retryProcess", // Ignored on iOS
        initialDelay: Duration(minutes: 30),
        constraints: Constraints(
          // connected or metered mark the task as requiring internet
          networkType: NetworkType.connected,
          // require external power
          requiresCharging: true,
        ),
        inputData: inputData // fully supported
    );
EDIT: Are OneOffTasks only available for devices with iOS 13+?
@ened Okay, I tested with an external device using iOS 15.6 with this PR and with 0.5.1:
PR works when testing app in the foreground. Could not test in the background because the command hangs when trying to test BGTaskScheduler until the app is brought to the foreground.
0.5.1 always returns null inputData despite the README docs claiming it's fully supported.
@AdamBridges what did you find out? I would be looking for storing input data in a hash table, specific to the supplied uniqueTaskName.
Pardon the delay: I've been trying to test things out on iOS but I can't escape this error on 0.5.1 before I try this PR:
flutter: PlatformException(unhandledMethod("registerOneOffTask") error, Unhandled method registerOneOffTask, null, null) flutter: #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7) #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18) <asynchronous suspension> #2 Workmanager.registerOneOffTask (package:workmanager/src/workmanager.dart:192:7) <asynchronous suspension>@ened Any ideas what's going on here?
Here's what I'm calling and doing so on a real iphone:
inputData ??= {}; inputData.addAll({ taskKey : uniqueTaskName, tagKey : retryProcessTag }); await Workmanager().registerOneOffTask( "task-identifier", "retryProcess", // Ignored on iOS initialDelay: Duration(minutes: 30), constraints: Constraints( // connected or metered mark the task as requiring internet networkType: NetworkType.connected, // require external power requiresCharging: true, ), inputData: inputData // fully supported );EDIT: Are OneOffTasks only available for devices with iOS 13+?
As i wrote, this PR is based on '0.5.0-dev.8'. Are you on this version ?
Yes, I have tested both. You can ignore that comment.
The one major caveat with this PR is that inputData likely gets overwritten if a different task is scheduled while one is pending because the background task key is always workmanager.background.task. However, 0.5.1 has corrected this issue so this PR should merge quite nicely and restore function to inputData.
@EArminjon @EArminjon2 Would you mind updating this PR to 0.5.1 with your changes to inputData?
Note that this PR is failing on Android.
Note that this PR is failing on Android.
This Pr works for 0.5.0-dev.8 and maybe an old version of flutter now....
I will not update this PR. I've not the time and the skills to do it... (I'm not a native developer). The PR was enough for the version 0.5.0-dev.8 because we cannot register multiple task. It was perfect for my app. Recent version can. Maintainer should fix it's package and handle the case of this PR.
The periodic register task of 15 minutes is completely working on Android but not working on iOS. I have to perform every 15 minutes task in iOS with the work manager how can I do it? Every time I get this error while registering periodic time with 15 mites in iOS. Anyone, please reply or suggest any other alternative solution to me.
Error: PlatformException(unhandledMethod("registerPeriodicTask") error, Unhandled method registerPeriodicTask, null, null)
The periodic register task of 15 minutes is completely working on Android but not working on iOS. I have to perform every 15 minutes task in iOS with the work manager how can I do it? Every time I get this error while registering periodic time with 15 mites in iOS. Anyone, please reply or suggest any other alternative solution to me.
Error: PlatformException(unhandledMethod("registerPeriodicTask") error, Unhandled method registerPeriodicTask, null, null)
This PR was working with the specified package version and maybe with flutter 2.10.5.
@all As this PR is not a bug ticket, please create a dedicated one and stop polute this topic with unrelated things please
Please give me an alternative solution, If you have any. Flutter 3.3.8 • channel stable • https://github.com/flutter/flutter.git Framework • revision 52b3dc25f6 (7 months ago) • 2022-11-09 12:09:26 +0800 Engine • revision 857bd6b74c Tools • Dart 2.18.4 • DevTools 2.15.0
Above is my flutter version.
Please give me an alternative solution, If you have any. Flutter 3.3.8 • channel stable • https://github.com/flutter/flutter.git Framework • revision 52b3dc25f6 (7 months ago) • 2022-11-09 12:09:26 +0800 Engine • revision 857bd6b74c Tools • Dart 2.18.4 • DevTools 2.15.0
Above is my flutter version.
I'm not the maintainer. I'm just a dev.
I opened this PR while I was working on a project whith a particular version of this package and flutter. I can't and will not provide support for newer version :') ! I just report a bug. All questions in this PR topic are mostly out of context. PLEASE CREATE DEDICATED ISSUE...
Why, did I create a dedicated issue? I will not create a dedicated issue. GIve me a solution first.
Why, did I create a dedicated issue? I will not create a dedicated issue. GIve me a solution first.
... I'm not the maintainer and i didn't have the solution for your issue. In addition it's a PR ticket not a bug ticket, in addition your issue is not linked to the PR.