Ski*_*ick 56
非技术性,但他们的常见问题解答提供了有关该技术的一些信息:
问:Bump如何运作?
答:Bump有两个部分:在您的设备上运行的应用程序和在云中的服务器上运行的智能匹配算法.手机上的应用程序使用手机的传感器来"感觉"碰撞,并将信息发送到云端.匹配算法监听来自世界各地的手机的颠簸,并将感觉相同的手机配对.然后我们只在每对中的两部手机之间路由信息.
问:没办法.如果有人在同一时间撞到怎么办?
答:方式.我们使用各种技术来限制潜在匹配池,包括位置信息和碰撞事件的特征.如果你碰到一个特别密集的区域(例如,在会议上),并且我们无法在单个碰撞后解决一个独特的匹配,我们只会要求你再次碰撞.我们的CTO拥有量子力学博士学位,可以展示其背后的数学,但我们建议您下载Bump并亲自尝试!
问:为什么Bump想要使用我的位置?
答:我们现在全球有数百万用户.我们使用位置信息作为限制我们必须检查以确定正确匹配的其他手机数量的方式之一.基本上,如果你在芝加哥,我们使用这些信息,所以我们不必将你的碰撞与来自日本,欧洲,纽约等的碰撞进行比较.出于这个原因,我们要求打开位置服务,并且用户授权使用其位置信息.如果您不授权使用位置信息,Bump将无法使用,抱歉.
问:Bump是否要求我的蓝牙也被激活?
A:没有!Bump根本不使用蓝牙工作; 您只需通过wifi,3G或Edge连接互联网.
完整示例来自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;
}
}];
Run Code Online (Sandbox Code Playgroud)
}