Post

Replies

Boosts

Views

Activity

Reply to NISession Background Apple Shareable Configuration Data in IOS 16
I have the same exact problem. I'm trying to run the interaction in the background using the Apple sample code changing this function.  func setupAccessory(_ configData: Data, name: String,peerIdentifier:UUID) {     updateInfoLabel(with: "Received configuration data from '\(name)'. Running session.")     do {                     //configuration = try NINearbyAccessoryConfiguration(data: configData)               if #available(iOS 16.0, *) {         print("ios 16 background configuration active")         configuration = try NINearbyAccessoryConfiguration(accessoryData: configData, bluetoothPeerIdentifier: peerIdentifier)       } else {         // Fallback on earlier versions         print("ios <16 background configuration not active")         configuration = try NINearbyAccessoryConfiguration(data: configData)       }     } catch {       // Stop and display the issue because the incoming data is invalid.       // In your app, debug the accessory data to ensure an expected       // format.       updateInfoLabel(with: "Failed to create NINearbyAccessoryConfiguration for '\(name)'. Error: \(error)")       return     }           // Cache the token to correlate updates with this accessory.     cacheToken(configuration!.accessoryDiscoveryToken, accessoryName: name)     niSession.run(configuration!)   }
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’22