AirNativeiOS-Bluetooth is a native extension to add Bluetooth support for iOS apps. The API mirrors the Objective-C API found in Apple GameKit and supports the features of the GKPeerPickerController
and relative GKSession
features only.
The extension provides enough functionality to connect with another Peer via the default iOS Bluetooth pop-up and send messages between each other.
Sample
// instantiating a connection var p2p:GKPeerToPeer = new GKPeerToPeer(); var picker:GKPeerPickerController = p2p.createGKPeerPickerController(); // wait for these events to know we've connected.. picker.addEventListener(GKPeerPickerControllerEvent.DID_CONNECT_PEER, onGKPeerPickerControllerEvent, false, 0, true ); picker.addEventListener(GKPeerPickerControllerEvent.CONTROLLER_DID_CANCEL, onGKPeerPickerControllerEvent, false, 0, true ); // the event handler for one of the above methods would contain: picker.removeEventListener(GKPeerPickerControllerEvent.DID_CONNECT_PEER, onGKPeerPickerControllerEvent ); picker.removeEventListener(GKPeerPickerControllerEvent.CONTROLLER_DID_CANCEL, onGKPeerPickerControllerEvent ); picker.dismiss(); // hides the iOS popup after connection. picker.dispose(); // remember to dispose!! // access the new GKSession object now we've connected. var session:GKSession = p2p.session; // then send a message session.sendDataToAllPeers( "Hello!", GKSendDataMode.RELIABLE ); // after use, disconnect and dispose session.disconnectFromAllPeers(); session.dispose();
Can you maybe send me a flash file which is using this .ane so I can see how it is set up? I do not manage to get it to work somehow
Hi, Thijs! You can try to find a FLA file in the Github repo of the lib. In case there is no FLA file, you can try to contact the author. Maybe he has something to help you.
Hi, a question pls.
// we use this line to send a message
session.sendDataToAllPeers( “Hello!”, GKSendDataMode.RELIABLE );
// how to do ?, if we want to use a bluetooth printer.
how to print some data?
thanks
Hi! This ANE will help you exchange data using a bluetooth channel, however you will not be able to print anything. In order to do that, you need to check how the printer communicates (its protocol), so you can send something that the printer will actually understand and print.