Nativescript - 引用 Android api 方法
Nativescript - referencing Android api methods
我在清单 VSCode(在 Android 下)中收到 syntax/undefined 错误。
android.Manifest.permission.READ_EXTERNAL_STORAGE
确切消息是 "Property 'Manifest' does not exist on type 'typeof android'."。
我没有定义 'android' - 但下面的示例也没有定义
我的 references.d.ts 文件看起来像
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.es2016.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
@dashman 你可以提供字符串而不是实际枚举来使用 nativescript-permissions 插件。
permissions.requestPermission([
"android.permission.INTERNET",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.SET_WALLPAPER",
"android.permission.ACCESS_NETWORK_STATE"
], "I need these permissions")
.then(function (res) {
console.log("Permissions granted!");
})
.catch(function () {
console.log("No permissions - plan B time!");
});
请注意,我正在传递一个 字符串数组 。
我在清单 VSCode(在 Android 下)中收到 syntax/undefined 错误。
android.Manifest.permission.READ_EXTERNAL_STORAGE
确切消息是 "Property 'Manifest' does not exist on type 'typeof android'."。
我没有定义 'android' - 但下面的示例也没有定义
我的 references.d.ts 文件看起来像
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.es2016.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
@dashman 你可以提供字符串而不是实际枚举来使用 nativescript-permissions 插件。
permissions.requestPermission([
"android.permission.INTERNET",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.SET_WALLPAPER",
"android.permission.ACCESS_NETWORK_STATE"
], "I need these permissions")
.then(function (res) {
console.log("Permissions granted!");
})
.catch(function () {
console.log("No permissions - plan B time!");
});
请注意,我正在传递一个 字符串数组 。