HUAWEI Health Kit provides developers with a user-defined running course import interface, which is convenient for users to view training schedules from ecological applications on Huawei Sports Health App and Huawei smart wearable devices, and start scientific and moderate exercise training.
The ability to import running courses supports ecological applications. After obtaining the authorization of the user's HUAWEI ID, the running course data is written to the Huawei Sports Health App, and when the existing Huawei smart wearable device is connected and supports course import, the class schedule is directly pushed to the device. On the Internet, users can easily and conveniently engage in scientific running course training to improve sports performance.
Before developers use the running course import function, please refer to Applying for the Health Kit service to complete the application for the following permissions:
Scope permissions corresponding to importing running courses: https://www.huawei.com/healthkit/location.write
The permission name of the Health Kit alliance card application: Health Management>Plan and task data.
The specific development process is as follows:
Import the running training plan to the Huawei Health App and display it.
If you need to deliver the device, you can use DeepLink to jump to the details page of the custom course of the Sports Health App, and automatically deliver the running course to the device (Huawei smart wearable devices need to support custom courses and have been integrated with the Sports Health App. bind).
Note: When the versionCode returned by the Huawei Sports Health App version number is not lower than 1300002300, the DeepLink jump function can be used.
sample code
Running training program import sample code.
request example
POST
https://health-api.cloud.huawei.com/healthkit/v1/trainingplan/workouts
Content-Type: application/json
Authorization: Bearer ***
x-client-id: ***
x-version: ***
x-caller-trace-id: ***
{
"name": "01:乳酸阈值课程",
"description": "总距离:7.02公里;总时间:1:19:00;训练负荷:29.7",
"actionCombine": [
{
"actionList": [
{
"name": "Warm up",
"describe": "暖身",
"target": {
"name": "time",
"value": 900.0
},
"strength": {
"name": "pace",
"valueH": 614000.0,
"valueL": 614000.0
}
}
],
"repeatTimes": 1
},
{
"actionList": [
{
"name": "relax",
"describe": "动态伸展",
"target": {
"name": "time",
"value": 300.0
}
}
],
"repeatTimes": 1
},
{
"actionList": [
{
"name": "run",
"describe": "跑步训练5分钟",
"target": {
"name": "time",
"value": 300.0
},
"strength": {
"name": "pace",
"valueH": 486000.0,
"valueL": 486000.0
}
},
{
"name": "have a rest",
"describe": "缓走或休息",
"target": {
"name": "time",
"value": 60.0
}
},
{
"name": "relax",
"describe": "静态伸展",
"target": {
"name": "time",
"value": 300.0
}
}
],
"repeatTimes": 9
}
]
}
example response
HTTP/1.1 200 OK
Content-type: application/json;charset=utf-8
{
"workoutId": "1669019290232",
"name": "01:乳酸阈值课程",
"description": "总距离:7.02公里;总时间:1:19:00;训练负荷:29.7",
"actionCombine": [
{
"repeatTimes": 1,
"actionList": [
{
"name": "Warm up",
"describe": "暖身",
"target": {
"name": "time",
"value": 900.0
},
"strength": {
"name": "pace",
"valueH": 614000.0,
"valueL": 614000.0
}
}
]
},
{
"repeatTimes": 1,
"actionList": [
{
"name": "relax",
"describe": "动态伸展",
"target": {
"name": "time",
"value": 300.0
}
}
]
},
{
"repeatTimes": 9,
"actionList": [
{
"name": "run",
"describe": "跑步训练5分钟",
"target": {
"name": "time",
"value": 300.0
},
"strength": {
"name": "pace",
"valueH": 486000.0,
"valueL": 486000.0
}
},
{
"name": "have a rest",
"describe": "缓走或休息",
"target": {
"name": "time",
"value": 60.0
}
},
{
"name": "relax",
"describe": "静态伸展",
"target": {
"name": "time",
"value": 300.0
}
}
]
}
],
"createTime": 1669019290232
}
The DeepLink Jump Sports Health App completes the automatic import of running courses.
Parameter Description
sample code
String deeplink="huaweischeme://healthapp/fitnesspage?skip_type=custom_course&id=workoutId&version=2.0";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(deeplink));
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
Learn more details>>
For more related content, please refer to the chapter on importing running courses .
If you need to know more functions, please visit the official website of Huawei Sports Health Service Alliance .
Visit the official website of HMS Core Alliance
Obtain the HMS Core development guidance document
Follow us and learn about the latest technical information of HMS Core for the first time~