简体   繁体   English

CLBeacon-从PeripheralData NSDictionary存储和提取信息吗?

[英]CLBeacon - Storing and Extracting Info From PeripheralData NSDictionary?

When you start advertising a CLBeacon with peripheral data, can you pass in a NSString or UIImage into this dictionary that you could then have show up when the beacon is discovered? 当您开始使用外围数据发布CLBeacon时,是否可以将NSString或UIImage传递到此字典中,然后在发现该信标时可以显示该字典?

For example, if I wanted to create write a message to a friend and then when the friend entered the beacon area, could I have the message show up on their phone by storing the message in the NSDictionary and then extracting it? 例如,如果我想创建一条消息给朋友,然后当朋友进入信标区时,可以通过将消息存储在NSDictionary中然后将其提取来使消息显示在他们的手机上吗? If so, how? 如果是这样,怎么办? If not, is there another way? 如果没有,还有其他方法吗?

Thanks! 谢谢!

So you are asking if you could add extra information to the beacon advertisement that's sent by a beacon device that a custom application could look for? 因此,您在问是否可以向自定义应用程序可以寻找的信标设备发送的信标广告中添加其他信息?

The answer is no. 答案是不。 The iBeacon protocol is a very short, fixed packet of data. iBeacon协议是一个非常短的固定数据包。 There's no facility for adding extra information to the packets. 没有为数据包添加额外信息的工具。

You could design and implement your own BLE service that's an alternative to iBeacons and implement it on both the transmitter and the receiver. 您可以设计和实现自己的BLE服务,以替代iBeacon,并在发送器和接收器上都实现它。

You could also use a hybrid approach, where you use standard iBeacon discovery to find beacons, and when you detect a beacon you're interested in, trigger a 2-way BLE conversation with the beacon and ask it for additional information. 您还可以使用混合方法,在其中使用标准iBeacon发现来找到信标,并且当您检测到感兴趣的信标时,触发与该信标的2向BLE对话,并询问其其他信息。 It's my understanding that some of the BLE devices that are being sold as iBeacons can run custom software that would implement this sort of thing. 据我了解,一些以iBeacons形式出售的BLE设备可以运行定制软件来实现这种功能。 (Many of these devices have ARM processors in them, the same family of chips that power iOS devices. (许多设备中都装有ARM处理器,这是为iOS设备供电的同一系列芯片。

No, you cannot do this. 不,您不能这样做。 iOS-based iBeacons (like all other standard iBeacons) will only transmit a three-part identifier and a transmitter power calibration value. 基于iOS的iBeacon(与所有其他标准iBeacons一样)将仅传输三部分标识符和发射机功率校准值。 That's it. 而已。 You cannot transmit anything else. 您无法传输其他任何内容。

Even if you did make a custom Bluetooth LE advertisement that sends additional data besides the standard iBeacon fields, you wouldn't be able to see this data with the standard APIs for seeing iBeacons. 即使您确实制作了自定义的蓝牙LE广告,除了标准iBeacon字段之外还发送其他数据,您也无法使用用于查看iBeacon的标准API来查看此数据。

If you want to tie other data to an iBeacon, you have to do it through another channel, by some kind of lookup that matches the data up with the identifiers above. 如果要将其他数据绑定到iBeacon,则必须通过另一种渠道,通过某种将数据与上面的标识符进行匹配的查找来完成。 Three common ways to do this: 三种常见的方法可以做到这一点:

  1. Hard-code a static lookup table in your app. 在您的应用中对静态查找表进行硬编码。
  2. Use a Web Service to look up the value based on the iBeacon identifiers. 使用Web服务基于iBeacon标识符查找值。
  3. Fetch the data directly from a (non-standard) iBeacon using a secondary BluetoothLE communication channel. 使用辅助BluetoothLE通信通道直接从(非标准)iBeacon提取数据。

My company has a web service called ProximityKit that makes it easy to tie data to iBeacons in your app. 我公司有一个称为ProximityKit的Web服务,可轻松将数据绑定到应用程序中的iBeacons。 You log into a web interface to type in key/value pairs to associate with each iBeacon, then the included iOS client library automatically gives you those key/value pairs when the iBeacon is visible. 您登录Web界面以键入与每个iBeacon关联的键/值对,然后,当iBeacon可见时,随附的iOS客户端库会自动为您提供这些键/值对。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM