External Accessory

RSS for tag

Communicate with accessories connected to a device by the Apple Lightning connector or through Bluetooth using External Accessory.

Posts under External Accessory tag

81 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Best Practice for Scheduling EASession Input and Output Streams
My company builds an application using the External Accessory framework to communicate with our hardware. We have followed the documentation and example here and use the stream delegate pattern for scheduling the handling of the EASession's InputStream and OutputStream: https://developer.apple.com/library/archive/featuredarticles/ExternalAccessoryPT/Articles/Connecting.html Our application works, however we have had some issues that cause us to doubt our implementation of the Stream handling for our EASession. All the examples I can find for how to set up this RunLoop based implementation for managing and using the streams associated with the EASession seem to use RunLoop.current to schedule the InputStream and OutputStream. What is not clear to me is what thread the processing of these streams is actually getting scheduled upon. We have occasionally observed our app "freezing" when our connected accessory disconnects, which makes me worry that we have our Stream processing on the main thread of the application. We want these streams to be processed on a background thread and never cause problems locking up our main thread or UI. How exactly do we achieve this? If we are indeed supposed to only use RunLoop.current, how can we make sure we're opening the EASession and scheduling its streams on a non-main thread? On what thread will we receive EAAccessoryDidConnect and EAAccessoryDidDisconnect notifications? Is it safe to schedule streams using RunLoop.current from that thread? What about when the app returns from the background, how are we meant to reconnect to an accessory that the iOS device is already connected to? Hopefully someone here can help guide us and shed some light on how to achieve our desired behavior here.
0
0
26
3h
Bluetooth keyboard events in fully immersive Vision Pro app?
I'm writing a Vision Pro app that's fully immersive and rendered using Metal. Occasionally, some users of this app would benefit from being able to use a physical keyboard (or other accessory like a game controller). It seems very straightforward to capture and handle spatial gesture events, but I cannot find an interface that allows the detection, capture, or handling of keyboard events in any of the objects associated with fully immersive metal rendering: CompositorServices, LayerRenderer, and its associated .frame, .drawable, and .drawable.view don't seem to have any accessory awareness. Can you help me handle a keyboard event?
2
0
264
1w
App running in background with External accessory background mode enabled doesn't receive sometimes the EAAccessoryDidConnect or the EAAccessoryDidDisconnect notification
Hi there! folks. Hope you are fine We want our two applications to listen to connection and disconnection notifications in the External accessory when we connect a device to USB These application are running in the background and we need to know when the device connects and disconnects from USB. In those cases, we have configured our apps to listen to local notifications as follows: EAAccessoryManager.shared().registerForLocalNotifications() NotificationCenter.default.addObserver(self, selector: #selector(didConnectAccessory(_:)), name: Notification.Name.EAAccessoryDidConnect, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(didDisconnectAccessory(_:)), name: Notification.Name.EAAccessoryDidDisconnect, object: nil) When the apps are running in foreground, everything works correctly. On the other hand, when the apps are running in the background mode and with the external accessory background mode enabled, the disconnection or connection event is not sent to the applications, causing them to not be able to initialize correctly. We attach traces of the two applications running in the background in a connection event through the USB. in The first application the Notification event is received correctly. In The second application the Notification event is NOT received correctly We would like to investigate with you what may be happening. We have opened a case in the feedback assistant (FB13800710) so you can investigate further. We open the case here so that other people can collaborate with us in depth. Thank you so much Looking forward to hearing from your side. All the best! LogsApplication
2
0
162
2w
How to run a background task on keyboard extension to communicate with a MFi device?
I'm working on a app that can communicate, send and receive data from our own MFi scanner. Ideally, this app can receives data and remains communication even when it's in background, but I can only runs a background task for maximum 30 sec. Along with this main app, we also have a keyboard extension as an interface that can publish collected data to other app that user prefers with string format. However, It seems like Apple doesn't allow to implement UIApplication.shared.beginBackgroundTask method in extension class, is there any alternative that worth to try? Also, can I extend app background task time elapsed to at least 30 minutes? If I can get an official response would be great!
1
0
416
Mar ’24
EAWiFiUnconfiguredAccessoryBrowser configureAccessory not showing UI modal up
Hello everyone, I'm trying to configure my WAC device trough an App. This App finds the device without problems using startSearchingForUnconfiguredAccessoriesMatchingPredicate but when I try to use configureAccessory method I get only 3 messages in Xcode and nothing happens. These messages are: 2024-03-14 12:55:56.261969+0000 App[1394:380785] ### WAC: -[EAWiFiUnconfiguredAccessoryBrowserManager configureAccessory:withConfigurationUIOnViewController:]_block_invoke_3:368 Other Region SKU 2024-03-14 12:55:56.266191+0000 App[1394:374248] ### WAC: _notificationCleanup:42 responseFlags: 3 ### WAC: _notificationCleanup:43 responseFlags: 3 For me they don't look like an Error but would be nice if someone could give me some advice on this, I didn't find nothing about it. Thanks in advance!
1
0
297
Mar ’24
Use external camera in background iOS app
Is there a possibility to develop an iOS app that is connected to an external camera connected through lightning or USB-C port and receives video stream. We need to be able to get this video stream even while the app is in the background or if the phone is locked. We could have the camera connected wirelessly through the lightning port. Is there an available library or a sample app featuring such functionalities. Thanks.
1
0
382
Feb ’24
Using External Accessory Framework in iOS App Development with MAUI
Hello, Apple Developer Community, I am currently developing an iOS application using .NET MAUI. In this application, I need to use the ExternalAccessoryFramework to communicate with external devices. However, I couldn't find any information about the compatibility of MAUI and ExternalAccessoryFramework, and I would like to confirm whether this combination is possible. Can an iOS app developed with MAUI use the ExternalAccessoryFramework? If so, could you provide any guidelines or reference materials about its implementation? I would greatly appreciate it if you could share your knowledge and experience. Thank you in advance.
1
0
356
Feb ’24
Wired data transfer between an app on two iOS/iPadOS devices--Possible or pipe dream?
If two iOS/iPadOS devices have your app opened, is it possible to have the apps send data to each other over a wired connection? E.g. If two iPhone 15s are connected by USB-C, can I get my app in iPhone A to send data to iPhone B and vice-versa? I've been looking around for quite a while now and at this point I just want to know if it's technically feasible.
5
0
635
Feb ’24
How to make the device communicate with the iPhone 15 APP using the USB-C interface?
Before iPhone 15, the lighting interfaces required communication with external devices through mfi authentication,But there is no evidence to suggest that the USB-C interface needs to add an MFi authentication chip for authentication detection. Is there a way to use USB-C to detect external devices and communicate with each other in the app now, so that I can create my app and communicate with hardware devices
1
1
530
Jan ’24
AirDrop iOS17
Hi all, hope everyone is well. I'm seeking clarification regarding AirDrop functionality in regards to apps. For example, can the new AirDrop function within iOS17, whereby putting two iPhones together transfers user contact details to one another be utilised by an app? If not, please could I have clarification what bluetooth functionality within iPhone's an App may be able to utilise and could an app connect to AirDrop API's in any way? If the new AirDrop feature is not currently able to be utilised by apps, is this likely to change in the future with upcoming iOS updates or is it a set in stone thing? Apologies, I don't have the deepest understanding of this topic and any help is really appreciated, thank you.
0
0
444
Jan ’24
EAWiFiUnconfiguredAccessoryBrowser not being able to detect device the OS is able to detect
Hey there 👋, My team and me have implemented support for WAC devices in our App using EAWiFiUnconfiguredAccessoryBrowser. When the device we want to support is factory reset we are able to find it as well as the OS is able to. The device has a "setup wifi" button, which starts the WAC process, and iOS (as well as MacOS) are able to find it. Unfortunately we are not able to find it in that case using EAWiFiUnconfiguredAccessoryBrowser.. I could not find any restrictions on it in the documentation, any glues why we are not able to detect it in that situation? I isolated the problem in a sample and used the following implementation to test this: import Foundation import ExternalAccessory import os import Combine class WACWatcher: NSObject { private let browser: EAWiFiUnconfiguredAccessoryBrowser private let logger = Logger(subsystem: "WACWatcher", category: "networking") @Published var accessories: [EAWiFiUnconfiguredAccessory] = [] override init() { self.browser = EAWiFiUnconfiguredAccessoryBrowser() super.init() self.browser.delegate = self } func start() { browser.startSearchingForUnconfiguredAccessories(matching: nil) } func stop() { browser.stopSearchingForUnconfiguredAccessories() } } extension WACWatcher: EAWiFiUnconfiguredAccessoryBrowserDelegate { func accessoryBrowser( _ browser: EAWiFiUnconfiguredAccessoryBrowser, didUpdate state: EAWiFiUnconfiguredAccessoryBrowserState ) { switch state { case .wiFiUnavailable: logger.debug("WAC Browser state changed to wifiUnavailable") break case .stopped: logger.debug("WAC Browser state changed to stopped") break case .searching: logger.debug("WAC Browser state changed to searching") break case .configuring: logger.debug("WAC Browser state changed to configuring") break } } func accessoryBrowser( _ browser: EAWiFiUnconfiguredAccessoryBrowser, didFindUnconfiguredAccessories accessories: Set<EAWiFiUnconfiguredAccessory> ) { logger.info("WACWatcher found accessories: \(accessories)") self.accessories.append(contentsOf: accessories) } func accessoryBrowser( _ browser: EAWiFiUnconfiguredAccessoryBrowser, didRemoveUnconfiguredAccessories accessories: Set<EAWiFiUnconfiguredAccessory> ) { logger.info("WACWatcher removed accessories: \(accessories)") self.accessories = accessories.filter({ accessory in accessories.contains(where: { $0.name == accessory.name }) }) } func accessoryBrowser( _ browser: EAWiFiUnconfiguredAccessoryBrowser, didFinishConfiguringAccessory accessory: EAWiFiUnconfiguredAccessory, with status: EAWiFiUnconfiguredAccessoryConfigurationStatus ) {} } This WACWatcher gets used in a ViewModel and a view having a start stop button and a list showing the device name. If you'd need to see it, I can zip it and attach it to this post.
1
0
366
Dec ’23
EAAccessory - bluetooth connectivity issue in specific region
One of our customers in US unable to connect to our device. current status: able to discover device, when trying to connect it throws an error " (error :Error Domain=EABluetoothAccessoryPickerErrorDomain Code=1 "(null)") " tried with different models, iPhone 11, iPhone XR, iPhone 15.. result is same. But It is working fine in Asia regions. Note: External accessory framework protocols has been added already in Info.plist. ( which has been registered in the MFi Program) Any help greatly appreciated. Thank you!
0
0
451
Dec ’23
Android Device is not Listing For iphone Devices for coreBluetoothScanning
Hello Apple Support Team, As per the business requirement, we have to communicate and exchange data chunks between applications running on iPhones and Android-based or Android phones through Bluetooth interface. We have achieved the requirement through IP/Wifi communication. We are trying to connect to Android and iPhone devices via Bluetooth through an iOS application. We carried out Bluetooth implementation using CoreBluetooth libraries. Below are the findings done by our development team: Core Bluetooth Library Implementation           Importing Core Bluetooth Library in BTConnectionManager class, which uses CBCentralManagerDelegate, CBPeripheralDelegate, CBCentralManager, CBPeripheral as peripheral, [CBPeripheral] array as peripherals array. Using the below methods: centralManagerDidUpdateState, centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber), centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral), peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?), peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: Service, error: Error?) we are able to scan and connect to BLE devices Findings: We were able to get the list of low-energy devices like Airpods, Earphones and Bluetooth music devices. But Not able to scan Bluetooth high-energy devices like PAX / Android Phones   Please suggest to us the approach to make the Android running devices listed through the Core Bluetooth library. Thanks & Regards
0
0
525
Nov ’23
Generic Protocol Specification for USB Flash Drive to communicate with IOS App
Hello Everyone, I am developing an IOS application for communicating with USB Flash Drive. For that I am going to use EAAccessory Framework. To be use EAAccessory Framework I need to mention protocol specification of USB Flash Drive (hardware) in info.plist file. Looking forward to know generic protocol specification which will enable IOS application to communicate with most or all USB flash drives.
2
0
469
Nov ’23
Macbook air 2020 gets stucks when miroring screen to an external display
I a macbook air 2020 m1 16Gb Ram and I'm having an annoying bug that started after i updated my mac to mac Sonoma 14.1. Whenever I connect an external display to my mac (hp e22 g4), mirror the screen and then start to watch a video the mac gets stuck. The keyboard doesn't respond, closing the lid doesn't help, only hard resetting the mac and causing to reboot seems to stop this. If I extend the display to the external monitor the bug doesn't occurs, it happen only when mirroring the screen. Tried different usb c to hdmi adapters, including high quality adapter, but it still happens. It didn't happened on older versions of mac os with the same adapter. Also, tried replacing the hdmi cable, but it doesn't seem to help. Can anyone help me with solving this issue? It's really annoying that I cant' mirror my mac's screen.
1
0
438
Nov ’23