I am trying to create a simple app using React Native that broadcasts an iBeacon. I have found a possible third-party module called react-native-ibeacon-simulator but even a simple test fails. I know this has not been updated for some time however I can't find a better solution...
I saved the index.ios.js
file as iBeacon.js
import React, { Component } from 'react'
import { Text, View } from 'react-native'
import ibeacon from './ibeacon'
export default class App extends Component {
componentWillMount() {
const uuid = '04bc1d42-98be-4031-a4a9-50c76cb3e1b9'
const identifier = 'com.myapp'
ibeacon.startAdvertisingBeaconWithString(uuid, identifier, 0, 0)
}
render() {
return (<View><Text>iBeacon</Text></View>)
}
}
However I get the following error in the terminal (and on the screen of the connected iPhone 6S running iOS13:
Warning: %s: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI., RootErrorBoundary
- node_modules/expo/build/environment/muteWarnings.fx.js:27:24 in error
- ... 28 more stack frames from framework internals
TypeError: null is not an object (evaluating 'NativeBeaconBroadcast.startSharedAdvertisingBeaconWithString')
* ibeacon.js:19:26 in startAdvertisingBeaconWithString
* App.js:12:43 in componentWillMount
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:7430:4 in callComponentWillMount
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:7576:27 in mountClassInstance
- ... 19 more stack frames from framework internals
I've tried debugging but can't figure out why this is happening...