iSaBo
iSaBo

Reputation: 165

React-Native - Beacon Manager - undefined is not an object

I get an error if i use the following code. I have run a "pod install", link the library manually. Nothing works.

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>
        )
    }
};

Does somebody know why the error occurs?

Upvotes: 1

Views: 738

Answers (1)

Kirill Novikov
Kirill Novikov

Reputation: 3067

IOS

For IOS we need to link it manually. Follow next steps:

  1. Drug RNiBeacon.xcodeproj from node_modules/react-native-beacons-manager/ios to Libraries folder in xcode

enter image description here

  1. Link it to your binaries:

enter image description here

  1. Add this path "$(SRCROOT)/node_modules/react-native-beacons-manager/ios" to Headers Search Paths for your App

enter image description here

  1. Add this paths $(SRCROOT)/../../../../ios/Pods/Headers/Public/React-Core, $(SRCROOT)/../../../../ios/Pods/Headers/Public/Yoga, $(SRCROOT)/../../../../ios/Pods/Headers/Public/YogaKit to Headers Search Paths for RNiBeacon:

enter image description here

Android

This library doesn't support new versions of react native for Android. You need to use forks: https://github.com/MacKentoch/react-native-beacons-manager/issues/249

https://github.com/MacKentoch/react-native-beacons-manager/issues/228#issuecomment-964131282

https://github.com/benlui/react-native-beacons-manager

depends on your need

Upvotes: 1

Related Questions