Problem:
On sports watch api6,error occurred when calling Context.requestPermissionsFromUser to obtain heart rate permission on the smart watch
Solution:
Context.requestPermissionsFromUser is for API7 and cannot be used on API6.
To obtain heart rate permission on the smart watch, simply declare the "ohos. permission. READ.HEALTH_DATA" permission in the config. json file, and call the interface on the page that needs to subscribe to the heart rate. This way, a heart rate permission dialog box will pop up when calling the interface that subscribes to the heart rate sensor for the first time.
If the user chooses to disable heart rate permission, the interface will report a 602 error. You can add a logic processing in the fail callback to guide the user to turn on heart rate authorization in the permission management
Top comments (0)