android - 错误 5000:应用程序在使用 cordova-plugin-health 查询活动数据时需要用户的 OAuth 同意
问题描述
使用 Cordova Health Plugin 2.0.2 我们目前可以检索步骤数据,但在查询活动时收到 5000 错误。
已完成 OAuth 设置步骤以进行测试,并添加了用于读取和写入 Activity 数据的范围。使用的域也已经过验证。
活动请求是:
this.cordova.health().requestAuthorization(dataTypes, () => {
this.cordova.health().isAuthorized(dataTypes, (authorized) => {
if(authorized) {
this.cordova.health().queryAggregated({
startDate: startDate.toDate(),
endDate: endDate.toDate(), // now
dataType: 'activity',
limit: 1000
}, (data) => {
配置文件
<preference name="android-minSdkVersion" value="22" />
<preference name="android-maxSdkVersion" value="30" />
<preference name="android-targetSdkVersion" value="29" />
<preference name="android-compileSdkVersion" value="29" />
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
<config-file parent="/*" target="config.xml">
<preference name="GradlePluginGoogleServicesEnabled" value="true" />
<preference name="GradlePluginGoogleServicesVersion" value="4.3.8" />
</config-file>
<config-file mode="merge" parent="/*" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.location.gps"
android:required="false" />
</config-file>
<preference name="AndroidXEnabled" value="true" />
<plugin name="cordova-plugin-health" spec="^2.0.2">
<variable name="HEALTH_READ_PERMISSION" value="App needs read access" />
<variable name="HEALTH_WRITE_PERMISSION" value="App needs write access" />
</plugin>
解决方案
推荐阅读
- python - 如何在 django 中链接到其他用户的个人资料?
- ios - 连接到蓝牙设备后应用程序不打印文本(Swift)
- keras - 如何训练模型外的参数?
- c++ - C ++数组初始化不适用于特定数量
- r - ifelse 在 R 数据框中添加计算字段
- java - 如何在 JAVA 中实现这个类图?
- vue.js - vue autocomplete with google places - 如何处理api key暴露
- javascript - 如果在 sheet2 的范围内发现 sheet1 上的值不起作用,则中断
- python - 尝试使用烧瓶邮件:AttributeError:“邮件”对象没有属性“发送”
- c - 使用 qsort 对返回 C 中的段错误的自定义 ADT 进行排序?