【问题标题】:React-Native - Beacon Manager - undefined is not an objectReact-Native - 信标管理器 - 未定义不是对象
【发布时间】:2022-12-10 12:01:17
【问题描述】:

如果我使用以下代码,我会收到错误消息。我运行了“pod install”,手动链接库。什么都不管用。

  • React-Native 版本:0.69.0
  • 库版本:1.0.7
import React, {Component} from 'react';

import {
    Text,
    TouchableOpacity, View
} from 'react-native';

// @ts-ignore
import {Beacons} from 'react-native-beacons-manager';


export default class App extends Component {
    componentDidMount() {
        Beacons.requestWhenInUseAuthorization();
        // Beacons.requestAlwaysAuthorization();
        // Beacons.allowsBackgroundLocationUpdates(true);
    }

    render() {
        return (
            <View>
                <Text style={{color: 'white', top: 150}}>test</Text>
            </View>
        )
    }
};

有人知道为什么会发生错误吗?

【问题讨论】:

  • 再次运行“pod install”后,出现错误:“错误:需要模块”node_modules/react-native-beacons-manager/lib/next/new.module.ios.js”,抛出异常:Invariant Violation : new NativeEventEmitter() 需要一个非空参数。”

标签: ios react-native


【解决方案1】:

这个库不支持新版本的 react native。您需要使用这个 fork https://github.com/MacKentoch/react-native-beacons-manager/issues/249 或这个 fork https://github.com/MacKentoch/react-native-beacons-manager/issues/228#issuecomment-964131282 取决于您的需要

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-21
    相关资源
    最近更新 更多