0

有人知道如何通过 uBudu Mesh Network 接收消息吗?

我正在开发一个使用 uBudu 信标的应用程序,总体思路是允许用户通过这些信标相互发送消息。我已经成功连接了 iOS-Mesh-SDK,如下所述:https ://github.com/Ubudu/IOS-Mesh-SDK 。

有一个如何将网格消息发送到另一个信标的示例,并且它工作得很好,但至于将这些消息从信标检索到用户应用程序,我不知道。

MeshBeacon 类中有方法:

- (void)abortMeshMessage;
- (void)clearMeshMessageQueue;

- (void)setMeshNotification:(BOOL)enable withCompletionBlock:(UMeshBeaconSuccessBlock)completionBlock;

但没有关于检索消息。

任何建议都非常感谢!

4

2 回答 2

0

我发现这个问题可能很粗暴,但可行的解决方案。

首先我们需要将自己设置为 BeaconManager 的代表

UBUMeshBeaconManager.sharedInstance().delegate = self

在委托方法的实现中,连接到最近的信标并将其外围委托重置为自身。

func meshManager(meshManager: UBUMeshBeaconManager!, didUpdateVisibleAndConnectableNodes meshNodes: [AnyObject]!) {
    UBUMeshBeaconManager.sharedInstance().connectToClosestBeacon({ (meshManager, meshBeacon, userInfo) -> Void in
            meshBeacon.peripheral.delegate = self
        }, progressBlock: { (meshManager, userInfo) -> Void in

        }, failedBlock: { (meshManager, meshBeacon, userInfo, error) -> Void in

        })
}

并等待 Peripheral Delegate 方法中的特征更新。UbuduSDK 将在幕后设置所有服务和特性。

func peripheral(peripheral: CBPeripheral!,
                didUpdateValueForCharacteristic characteristic: CBCharacteristic!,
                error: NSError!) {
    var string = NSString(data: characteristic.value, encoding: NSASCIIStringEncoding)
    println(string)
}
于 2015-07-21T11:13:30.297 回答
0

正如您正确指出的那样,SDK 还没有接收消息的方法,但是有一个支持此功能的库更新。

于 2015-07-21T06:49:52.670 回答