有没有关于进行设备到设备数据传输的好的文档或文章?
3 回答
相当非技术性,但他们的常见问题解答提供了有关该技术的一些信息:
问:Bump 是如何工作的?
答:Bump 有两个部分:在您的设备上运行的应用程序和在我们的云服务器上运行的智能匹配算法。手机上的应用程序使用手机的传感器来“感受”撞击,并将该信息发送到云端。匹配算法会聆听来自世界各地手机的颠簸,并将感受到相同颠簸的手机配对。然后我们只需在每对中的两部手机之间路由信息。
问:没办法。如果其他人同时撞到怎么办?
离开。我们使用各种技术来限制潜在匹配池,包括位置信息和碰撞事件的特征。如果您在特别密集的区域(例如,在会议上)进行碰撞,并且在一次碰撞后我们无法解决唯一匹配,我们只会要求您再次碰撞。我们的 CTO 拥有量子力学博士学位,可以展示其背后的数学原理,但我们建议下载 Bump 并自己尝试!
问:为什么 Bump 要使用我的位置?
答:我们现在在全球拥有数百万用户。我们使用位置信息作为限制我们必须检查以确定正确匹配的其他手机数量的方法之一。基本上,如果您在芝加哥,我们会使用该信息,因此我们不必将您的颠簸与来自日本、欧洲、纽约等地的颠簸进行比较。因此,我们要求打开定位服务并且用户授权使用他们的位置信息。如果您不授权使用位置信息,Bump 将无法工作,抱歉。
问:Bump 是否要求我的蓝牙也被激活?
答:不!Bump 根本不使用蓝牙工作;您只需要通过 wifi、3G 或 Edge 连接互联网。
您可能会混淆 Bump 的功能。我的理解是加速度计和地理位置数据用于识别候选“颠簸”或设备对。联系人数据本身是通过 Internet 传输的,而不是通过蓝牙或 wifi 在本地传输。
来自https://github.com/bumptech/bump-api-ios的完整示例
- (void) configureBump {
// userID is a string that you could use as the user's name, or an ID that is semantic within your environment
[BumpClient configureWithAPIKey:@"your_api_key" andUserID:[[UIDevice currentDevice] name]];
[[BumpClient sharedClient] setMatchBlock:^(BumpChannelID channel) {
NSLog(@"Matched with user: %@", [[BumpClient sharedClient] userIDForChannel:channel]);
[[BumpClient sharedClient] confirmMatch:YES onChannel:channel];
}];
[[BumpClient sharedClient] setChannelConfirmedBlock:^(BumpChannelID channel) {
NSLog(@"Channel with %@ confirmed.", [[BumpClient sharedClient] userIDForChannel:channel]);
[[BumpClient sharedClient] sendData:[[NSString stringWithFormat:@"Hello, world!"] dataUsingEncoding:NSUTF8StringEncoding]
toChannel:channel];
}];
[[BumpClient sharedClient] setDataReceivedBlock:^(BumpChannelID channel, NSData *data) {
NSLog(@"Data received from %@: %@",
[[BumpClient sharedClient] userIDForChannel:channel],
[NSString stringWithCString:[data bytes] encoding:NSUTF8StringEncoding]);
}];
// optional callback
[[BumpClient sharedClient] setConnectionStateChangedBlock:^(BOOL connected) {
if (connected) {
NSLog(@"Bump connected...");
} else {
NSLog(@"Bump disconnected...");
}
}];
// optional callback
[[BumpClient sharedClient] setBumpEventBlock:^(bump_event event) {
switch(event) {
case BUMP_EVENT_BUMP:
NSLog(@"Bump detected.");
break;
case BUMP_EVENT_NO_MATCH:
NSLog(@"No match.");
break;
}
}];
}