react-native - null 不是对象(评估“RNCalendarEvents.authorizationStatus”)
问题描述
我正在尝试使用此包“从'react-native-calendar-events'导入RNCalendarEvents;”在日历电话中放置一个事件 但我有这个错误“null不是对象(评估'RNCalendarEvents.authorizationStatus')”
import RNCalendarEvents from 'react-native-calendar-events
onPressAdd() {
if (Platform.OS === 'ios') {
RNCalendarEvents.authorizationStatus()
.then(status => {
console.log(status)
})
.catch(error => {
console.log(error)
});
}
}
解决方案
我想我在安装模块时没有向 iOS android 添加依赖项。
你尝试运行react-native link react-native-calendar-events
编辑
请删除该模块并尝试从头开始安装。
npm install --save react-native-calendar-events
react-native link react-native-calendar-events
用法
import RNCalendarEvents from 'react-native-calendar-events';
RNCalendarEvents.authorizationStatus()
如果这是不可能的,它可能不可用,因为它是以前制作的模块。
如果您正在检查日历上的权限,则可以使用此模块替换它。
import {PermissionsAndroid} from 'react-native';
async function checkPermission() {
write_calender = await PermissionsAndroid.WRITE_CALENDAR
read_calender = await PermissionsAndroid.READ_CALENDAR
if (granted === PermissionsAndroid.check(write_calender) &&
granted === PermissionsAndroid.check(read_calender)) {
console.log('You can use the CALENDAR');
} else {
console.log('CALENDAR permission denied');
}
}
推荐阅读
- node.js - toLocaleString() 显示不同的结果
- perl - 在 Perl 中,哈希和祝福引用之间的根本区别是什么?
- javascript - 使用 flickity 滑块,屏幕下降的问题
- javascript - uesRef 和 react-slick 刷新时不渲染
- reactjs - REACT-DATE-PICKER 当 maxDate 小于当前月份或年份时,日历在打开时显示当前月份
- c# - 如何将内部列表复制到新列表
- webview - 我的 html 本地文件没有从 webView 打开 .. 请帮帮我
- javascript - 如何将图像添加到 Excel 并使用 react-data-export 包导出
- dictionary - 如何将字符串附加到字符串映射到接口类型
- xamarin.forms - xamarin.forms 的 Appcenter 构建失败