Refactored Swift native implementation #1175
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors the Swift native implementation. It introduces the following new classes:
HealthDataWriter
: writing health data to HealthKit functionsHealthDataReader
: reading health data from HealthKit functionsHealthDataOperations
: managing data permissions and delete functionsHealthConstants
: constants used in the plugin (where types are introduced)HealthUtilities
: helper functions - also includes type conversion helpers forHKWorkoutActivityType
The initialisation of these classes are lazy now to help with performance.
In the new approach, when defining a new method for iOS native, for better error handling the cases should be handled as follow under the
handle(_ call: FlutterMethodCall, result: @escaping FlutterResult)
function:This now requires each new method to throw an error in case of failure.
Supported error codes to be used:
REQUEST_AUTH_ERROR
: Error requesting authorisationPERMISSION_ERROR
: Error checking permissionsWRITE_ERROR
: Error writing [DataType]DELETE_ERROR
: Error deleting dataARGUMENT_ERROR
: Missing required argumentINVALID_TYPE
: Invalid dataTypeKeyHEALTH_ERROR
: Error getting health dataINTERNAL_ERROR
: Internal instance reference lostSTATISTICS_ERROR
: Error getting statisticsSTEPS_ERROR
: Error getting step count