我正在尝试在运行时寻求许可。我收到TypeError:Object(...)不是AndroidPermissions.requestPermission中的函数...
import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
this.platform.ready().then(() => {
this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then((data: any) => {
if (data.hasPermission) {
console.log("have permission");
}
});
})
错误
TypeError: Object(...) is not a function
at AndroidPermissions.requestPermission (vendor.js:63232)
at HomePage.webpackJsonp.139.HomePage.getPermission (main.js:75)
at main.js:67
at t.invoke (polyfills.js:3)
at Object.onInvoke (vendor.js:5134)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (vendor.js:5125)
答案 0 :(得分:0)
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE]).then(
success => {
this.presentToast("Has permission? "+ success,"toast-warning")
},
err => this.androidPermissions.requestPermissions(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE)
);
答案 1 :(得分:0)
对于任何寻求答案的人,
这是版本问题,更新了android-permissions和core。
"@ionic-native/android-permissions": "^5.1.0"
"@ionic-native/core": "^5.1.0"
感谢此answer