- You must head to https://developer.huawei.com/consumer/en/ and create your account and app account.
- This plugin is a wrapper for their
.jar
and android implementation. - Head to this link if you prefer to implement it yourself.
- HiHealth is only available on Android. For iOS, use Apple Health.
- Register yourself or your company at https://developer.huawei.com/.
- Register your app at Console > Smart Living > HiHealth Kit
- You may need to tweak gradle depends if you are using your own keystore. Keystore is ignored.
Running example
- Create a copy of
example.properties
from example.properties.bak - Replace your data in example.properties
- Run the project.
Using in your own project
- Add this into your
AndroidManifest.xml
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="${huaweiID}"/>
- Add to
pubspec.yaml
huawei_health: any
- Import
import 'package:hi_health/hi_health.dart';
To get the Steps data:
Future getSteps() async {
final start = DateTime.now().subtract(Duration(days: 5));
final end = DateTime.now();
final steps = await HiHealth.getSteps(start, end);
}
To get the distance data:
Future getDistances() async {
final start = DateTime.now().subtract(Duration(days: 5));
final end = DateTime.now();
final distances = await HiHealth.getDistance(start, end);
}
If you enable minify, add this line into your proguard rules. This will avoid exception when unmarshalling class.
-keep class com.huawei.hihealth.* {
public *;
}