【问题标题】:Trying to Broadcast an iBeacon using React Native尝试使用 React Native 广播 iBeacon
【发布时间】:2020-04-02 01:09:55
【问题描述】:

我正在尝试使用广播 iBeacon 的 React Native 创建一个简单的应用程序。我找到了一个可能的第三方模块react-native-ibeacon-simulator,但即使是简单的测试也失败了。我知道这已经有一段时间没有更新了,但是我找不到更好的解决方案...

我将index.ios.js 文件保存为 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>)
    }
}

但是我在终端(以及运行 iOS13 的已连接 iPhone 6S 的屏幕上)出现以下错误:

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

我试过调试,但不知道为什么会这样……

【问题讨论】:

  • 我也遇到了同样的问题...运气好吗?

标签: ios node.js react-native ibeacon


【解决方案1】:

这可能对您没有帮助,但如果您查看软件包中可用的已知设备列表,iOS 根本没有列出。我认为该软件包支持大量我从未听说过但无法支持超级流行的 Apple 产品的设备,这令人难以置信。

手机和平板电脑

  • Google Pixel [XL]、Pixel C、Nexus 6P、6、5X、9、修补过的 Nexus 5
  • 阿尔卡特 One Touch Idol 3 [双卡],Fierce XL
  • 华硕 Zenfone 2 [激光]、Zenpad 8
  • 黑莓隐私
  • HTC 10,一个 M9,Desire (530/626s/820)
  • 华为Ascend Y550,荣耀5X,优联
  • 联想 K3 Note、Vibe P1m、Vibe K4 Note
  • LG:G5、G4 [Stylus]、G3、G Flex2、G Vista 2、V10、K10、L Bello、Lancet、Leon、Magna、Optimus Zone 3、Spirit、Tribute 5
  • Moto X Play、X Style、X2、G2、G3、G4、Z Droid、Droid Turbo 2
  • Nextbit 罗宾
  • 一加 2、3
  • OPPO A33f
  • Samsung Galaxy:S7 [Edge] - 最多 8 个并发运行的 BLE 广告商、S6 [Active/Edge/Edge Plus]、S5 [Active/Neo]、Note 5、Note Edge、Note 4、Tab S2 (8.0/ 9.7)、Tab S (8.4/10.5)、Note Pro、Tab A 9.7、Tab E、A5 2016 [Duos]、J5、J3 Duos、Alpha、Core Prime、Grand Prime、On7
  • Sony Xperia E5、X、Z5 [Compact/Premium]、C5 Ultra、C3、M4 Aqua [Dual]
  • 小米红米3、Note 2、Note 3、小米4、小米4i、小米5、小米Max
  • 中兴 Maven、ZMAX 2、Zmax Pro、Warp Elite

Android 电视

  • 索尼 Bravia 2015

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-16
    • 2022-01-02
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多