NISession Background Apple Shareable Configuration Data in IOS 16

 var peerIdentifier = peripheral!.identifier     do {       configuration = try NINearbyAccessoryConfiguration(accessoryData: accessoryData, bluetoothPeerIdentifier: peerIdentifier)     }catch{       return     }     cacheToken(configuration!.accessoryDiscoveryToken, accessoryName: devicename)     nisession?.run(configuration!)


I configured the source as above, how do I receive Apple Shareable Configuration Data

sessionFailed : Error Domain=com.apple.NearbyInteraction Code=-5887 "NIERROR_SESSION_FAILED_DESCRIPTION" UserInfo={NSLocalizedRecoverySuggestion=NIERROR_SESSION_FAILED_RECOVERY_SUGGESTION, NSLocalizedDescription=NIERROR_SESSION_FAILED_DESCRIPTION, NSLocalizedFailureReason=This session object is invalidated. Dispose of it and create a new one instead.}

Replies

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!)
  }

Did you get to any point on this?

Thanks

FedericoLotta how are you getting 'accessoryConfigData'? From Bluetooth device Service -> Charactristic?

I have the same issue, NINearbyAccessoryConfiguration(data: configData) is ok to run, but NINearbyAccessoryConfiguration( accessoryData: configData,bluetoothPeerIdentifier:peerIdentifier) cannot work,
The error information is "Domain=com.apple.NearbyInteraction Code=-5887 "NIERROR_SESSION_FAILED_DESCRIPTION""

Did somebody found a fix for this? I'm having the same issue