Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

New datatypes in v1.1.1 have broken compatibility w/ older versions of iOS #36

Closed
carlleeswanson opened this issue Jan 22, 2020 · 5 comments

Comments

@carlleeswanson
Copy link

The addition of "STAND_TIME" appears to have made this package incompatible with iOS 12.4 (presumably other older iOS versions also).

FitKit.requestPermissions(DataType.values) always throws the following error:
PlatformException(FitKit, Error type "stand time" is not supported, null)

Removing "STAND_TIME" from fit_kit.dart solves the problem.
Oddly, "EXERCISE_TIME" doesn't generate an error.

@MelanieGravel
Copy link

I got the exact same error.

HKQuantityTypeIdentifier' has no member 'appleStandTime', on the Extensions.swift file

@softmarshmallow
Copy link

Also android raises error with the same comment. STAND_TIME

@janosdupai
Copy link

Same here.

PlatformException(FitKit, type stand_time is not supported, null) - on Android device. Any idea?

@khmurakami
Copy link

@janosdupai
@softmarshmallow
@carlleeswanson

In the example folder it has this line,

permissions = await FitKit.requestPermissions(DataType.values);

It doesn't work on Android because Standtime is not supported. The README.md shows the supported types.

DataType.values is a List of all the possible values which includes the ones supported in iOS.

The way to go about this, is to declare a new list and then pass in these values instead for Android.

  List<DataType> androidValues = [
    DataType.ENERGY,
    //DataType.EXERCISE_TIME,
    DataType.DISTANCE,
    DataType.STEP_COUNT,
    DataType.WATER,
    DataType.WEIGHT,
    DataType.HEIGHT,
    DataType.HEART_RATE,
    //DataType.STAND_TIME,
  ];

permissions = await FitKit.requestPermissions(androidValues);

@krokyze
Copy link
Owner

krokyze commented Jun 14, 2020

Starting from version 1.1.2 it's advised to wrap all read methods inside try catch as FitKit.read will throw specific UnsupportedException

void read() async {
  try {
    final results = await FitKit.read(
      DataType.HEART_RATE,
      dateFrom: DateTime.now().subtract(Duration(days: 5)),
      dateTo: DateTime.now(),
    );
  } on UnsupportedException catch (e) {
    // thrown in case e.dataType is unsupported
  }
}

@krokyze krokyze closed this as completed Jun 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants