BTFileTransfer is a subclass of NSObject that lets you transfer any kind of data (from simple text to complex files) via Bluetooth.
Great for "bumping" a vCard or settings between two devices.
The demo app included with your purchase lets you send photos from one iOS device to another (tested and confirmed working on iPhone, iPad and iPod Touch).
Video of the demo app running on iPhone 4 and iPad 2
Deployment target: Tested with iOS 5 and later
ARC compatible
Bonus 1: Buyers of the developer license can request features that might be implemented later
Bonus 2: Demo app "BTChat" available to everyone soon after release (like Messages app but Bluetooth) [Screenshot]
Drag both files – BTFileTransfer.h and BTFileTransfer.m into your project and link against GameKit.framework.
Create a new instance of BTFileTransfer like this
_fileTransfer = [[BTFileTransfer alloc] init];
and assign "self" as the delegate of BTFileTransfer like this
_fileTransfer.delegate = self;
Implement at least the required delegate method of the BTFileTransferDelegate protocol. According to the header it is
- (void)fileReceived:(NSData *)data {
}
"Pair" by calling
[_fileTransfer pair];
After the delegate method
- (void)peerConnected:(NSString *)displayName {
}
got called you can send data or a file using one of the two available methods:
UIImage *image;
NSError *error;
[_fileTransfer sendData:UIImageJPEGRepresentation(image, 0.8) error:&error];
Like that you can also send strings, arrays or a dictionary.
To send a file from the local filesystem:
NSString *path;
NSError *error;
[_fileTransfer sendFile:path error:&error];
@property (strong) NSString *displayName;
Human-readable name identifying the current device
Device name is used if not set
- (void)fileTransferInProgress:(unsigned int)expectedLength;
Called when receiving a file on the device receiving it.
You can present the user with an alert telling him the size of the file.
Questions & Comments