This is an all-new version of the Bump iOS API.
[BumpClient configureWithAPIKey:@"your_api_key" andUserID:[[UIDevice currentDevice] name]];
Congrats, that's it. Your app is now bumpable!
3.0
matchBlock
when a match occurs. In order to create a channel (and send data), both users most call [[BumpClient sharedClient] confirmMatch:YES onChannel:channel];
. When both users confirm a channel, then BumpClient
will callback its channelConfirmedBlock
.- (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;
}
}];
}