バンプの API を正しく実装し、次のコードを追加しました。
- (void) configureBump {
[BumpClient configureWithAPIKey:@"your api key" andUserID:[[UIDevice currentDevice] name]];
[[BumpClient sharedClient] setMatchBlock:^(BumpChannelID channel) {
/* UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Matched with user" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil ];
[alert show];
[alert release];*/
NSLog(@"Matched with user: %@", [[BumpClient sharedClient] userIDForChannel:channel]);
[[BumpClient sharedClient] confirmMatch:YES onChannel:channel];
}];
[[BumpClient sharedClient] setChannelConfirmedBlock:^(BumpChannelID channel) {
/* UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Channel with" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil ];
[alert show];
[alert release];*/
NSLog(@"Channel with %@ confirmed.", [[BumpClient sharedClient] userIDForChannel:channel]);
[[BumpClient sharedClient] sendData:[[NSString stringWithFormat:@"hi"] dataUsingEncoding:NSUTF8StringEncoding]
toChannel:channel];
}];
[[BumpClient sharedClient] setDataReceivedBlock:^(BumpChannelID channel, NSData *data) {
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Data received" message:[NSString stringWithCString:[data bytes] encoding:NSUTF8StringEncoding] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil ];
[alert show];
[alert release];
NSLog(@"Data received from %@: %@",
[[BumpClient sharedClient] userIDForChannel:channel],
[NSString stringWithCString:[data bytes] encoding:NSUTF8StringEncoding]);
NSString *receivedBumpData=[NSString stringWithCString:[data bytes] encoding:NSUTF8StringEncoding];
if(receivedBumpData.length!=0){
CardAvailableLandscape *cardObject=[[CardAvailableLandscape alloc] init];
[cardObject bumpInsertFunction:receivedBumpData];
}
}];
[[BumpClient sharedClient] setConnectionStateChangedBlock:^(BOOL connected) {
if (connected) {
/* UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"bump Coneected" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil ];
[alert show];
[alert release];*/
NSLog(@"Bump connected...");
} else {
/* UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Bump disconnected..." message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil ];
[alert show];
[alert release];*/
NSLog(@"Bump disconnected...");
}
}];
[[BumpClient sharedClient] setBumpEventBlock:^(bump_event event) {
switch(event) {
case BUMP_EVENT_BUMP:{
/*UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Bump detected." message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil ];
[alert show];
[alert release];*/
NSLog(@"Bump detected.");
break;
}
case BUMP_EVENT_NO_MATCH:
{
/*UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"No match." message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil ];
[alert show];
[alert release];*/
NSLog(@"No match.");
break;
}
}
}];
}
このコードは、サンプル プロジェクトから取得したものです。接続が確立されます。しかし、ファイルを送信できないようです: このチュートリアルを試しました:
http://appgenor.blogspot.it/2010/02/using-bumps-new-api-to-exchange-data.html
しかし、Bumb オブジェクトは作成できません。エラーが発生します。バンプは実装されていません。それはsdkにはないので、私は思う...
bumpObject = [[Bump alloc] init]; // Bump *bumpObject;
助けてください!!