Problems device ownership doing Simple Authentication in my iOS app

Hello,

I have problems with the Simple Authentication in my iOS app.
The setup process always fails when it tries to verify the device ownership

And shows this message.

In the setup process, it also asks my me whether I want to override the ownership (I unclaimed it before from my main account).

After the failed setup, the photon is in the connected mode and breathing cyan. Also, it has no problems to connected after a restart.
However, neither is the Photon shown anymore in my main account nor it is registered as a device in my product.

I already tried several times pressing the setup button for 10 seconds like it was mentioned here but it didn’t work.

I also don’t see in the console the customer I created but he seems to be there, because when I log out I can only log in with the right credentials.

This is my code in XCode.
In the AppDelegate class I added the keys.
I wasn’t sure what to use for organizationSlug and productSlug but I read the four-digit product ID would be right.
I also tried it without vc.delegate = self but with the same result and more errors in the beginning.

func customizeSetup(){
    let c = SparkSetupCustomization.sharedInstance()
    c?.brandName = "EDEN"
    c?.brandImageBackgroundColor = UIColor(red: 0.2, green: 0.2, blue: 0.96, alpha: 0.9)
    c?.deviceName = "Sensor"
    c?.modeButtonName = "Sensor Button"
    c?.listenModeLEDColorName = "Pink"
    c?.networkNamePrefix = "Photon"
    c?.pageBackgroundColor = UIColor(colorLiteralRed: 0.2, green: 0.2, blue: 0.96, alpha: 0.9)
    c?.organization = true
    c?.organizationSlug = "3577" 
    c?.productSlug = "3577" 
    c?.allowSkipAuthentication = true
}

func sparkSetupViewController(_ controller: SparkSetupMainController!, didFinishWith result: SparkSetupMainControllerResult, device: SparkDevice!) {
    switch result
    {
    case .success:
        print("Setup completed successfully")
    case .userCancel :
        print("User cancelled setup")
    case .loggedIn :
        print("User is logged in")
    default:
        print("Uknown setup error")
    }
    if device != nil
    {
        device.getVariable("test", completion: { (value, err) -> Void in
        })
    }
}

func insertNewObject(_ sender: Any) {
    self.customizeSetup()
    if let vc = SparkSetupMainController()
    {
        let c = SparkSetupCustomization.sharedInstance()
        vc.delegate = self //https://community.particle.io/t/does-anyone-have-a-working-xcode-8-swift-3-project-with-oauth-simple-auth-they-mind-sharing/26670/8
        vc.modalPresentationStyle = .formSheet  // use that for iPad
        self.present(vc, animated: true, completion: nil)
    }
    self.tableView.reloadData()
}

This is the console output with vc.delegate

2017-03-11 20:07:05.504540 EDEN-V2[4241:1531311] [Accessibility] ****************** Loading GAX 

Client Bundle ****************
2017-03-11 20:07:41.993475 EDEN-V2[4241:1531311] DeviceID sent
2017-03-11 20:07:45.082567 EDEN-V2[4241:1531311] Could not send device-id command: Timeout occured while waiting for response from socket
2017-03-11 20:07:48.134192 EDEN-V2[4241:1531311] DeviceID sent
2017-03-11 20:07:48.173958 EDEN-V2[4241:1531311] DeviceID response received: 410037000a47353235303037
2017-03-11 20:07:48.174095 EDEN-V2[4241:1531311] PublicKey sent
2017-03-11 20:07:48.212609 EDEN-V2[4241:1531311] PublicKey response received
2017-03-11 20:07:48.212866 EDEN-V2[4241:1531311] ScanAP sent
2017-03-11 20:07:50.672416 EDEN-V2[4241:1531311] ScanAP response received
2017-03-11 20:07:53.296807 EDEN-V2[4241:1531311] button index 0
2017-03-11 20:07:53.296982 EDEN-V2[4241:1531311] Claim code - trying to set
2017-03-11 20:07:53.689955 EDEN-V2[4241:1531311] Device claim code set successfully: MxB4ydZSTlX0tcK+Fv29Xe9OGNFHZjDc3tlQnZ49R565ImuKaWKhYraaFS9ZRpi
2017-03-11 20:07:55.363136 EDEN-V2[4241:1531311] sparkSelectNetworkVC prepareForSegue : require_password
2017-03-11 20:07:55.936910 EDEN-V2[4241:1531311] Unbalanced calls to begin/end appearance transitions for <SparkSelectNetworkViewController: 0x100d90da0>.
2017-03-11 20:08:11.504414 EDEN-V2[4241:1531311] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-03-11 20:08:11.512292 EDEN-V2[4241:1531311] [MC] Reading from public effective user settings.
2017-03-11 20:08:15.376761 EDEN-V2[4241:1531311] configureAP sent
2017-03-11 20:08:27.539919 EDEN-V2[4241:1531311] configureAP sent
2017-03-11 20:08:27.540400 EDEN-V2[4241:1531311] Could not send device-id command: The operation couldn’t be completed. Socket is not connected
2017-03-11 20:08:27.540760 EDEN-V2[4241:1531311] Error sending public-key command to target: The operation couldn’t be completed. Socket is not connected
2017-03-11 20:08:27.541133 EDEN-V2[4241:1531311] Could not send scan-ap command: The operation couldn’t be completed. Socket is not connected
2017-03-11 20:08:27.541447 EDEN-V2[4241:1531311] Could not send set command: The operation couldn’t be completed. Socket is not connected
Uknown setup error

And this is it without

    2017-03-11 17:23:35.458145 EDEN-V2[4170:1505942] -canOpenURL: failed for URL: "org-appextension-feature-password-management://" - error: "This app is not allowed to query for scheme org-appextension-feature-password-management"
2017-03-11 17:23:37.340414 EDEN-V2[4170:1505942] -canOpenURL: failed for URL: "org-appextension-feature-password-management://" - error: "This app is not allowed to query for scheme org-appextension-feature-password-management"
2017-03-11 17:23:38.410364 EDEN-V2[4170:1505942] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-03-11 17:23:38.418090 EDEN-V2[4170:1505942] [MC] Reading from public effective user settings.
2017-03-11 17:24:17.095074 EDEN-V2[4170:1505942] Cannot snapshot view (<UIKeyboardImpl: 0x100e54300; frame = (0 0; 375 216); layer = <CALayer: 0x1702216a0>>) with afterScreenUpdates:NO, because the view is not in a window. Use afterScreenUpdates:YES.
2017-03-11 17:24:38.488674 EDEN-V2[4170:1505942] DeviceID sent
2017-03-11 17:24:41.504514 EDEN-V2[4170:1505942] Could not send device-id command: Timeout occured while waiting for response from socket
2017-03-11 17:24:44.555505 EDEN-V2[4170:1505942] DeviceID sent
2017-03-11 17:24:44.568558 EDEN-V2[4170:1505942] DeviceID response received: 410037000a47353235303037
2017-03-11 17:24:44.568739 EDEN-V2[4170:1505942] PublicKey sent
2017-03-11 17:24:44.607467 EDEN-V2[4170:1505942] PublicKey response received
2017-03-11 17:24:44.607617 EDEN-V2[4170:1505942] ScanAP sent
2017-03-11 17:24:46.965203 EDEN-V2[4170:1505942] ScanAP response received
2017-03-11 17:25:19.520515 EDEN-V2[4170:1505942] button index 0
2017-03-11 17:25:19.520684 EDEN-V2[4170:1505942] Claim code - trying to set
2017-03-11 17:25:19.837113 EDEN-V2[4170:1505942] Device claim code set successfully: RBcTvu45/h+nqm0Lgv5hrj9qiLx1U6Gprk8oCjnzyiTUgqsBKBPlO15PSdPMykg
2017-03-11 17:25:21.265818 EDEN-V2[4170:1505942] sparkSelectNetworkVC prepareForSegue : require_password
2017-03-11 17:25:21.834490 EDEN-V2[4170:1505942] Unbalanced calls to begin/end appearance transitions for <SparkSelectNetworkViewController: 0x100eb60b0>.
2017-03-11 17:25:24.747279 EDEN-V2[4170:1505942] Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
2017-03-11 17:25:36.177336 EDEN-V2[4170:1505942] configureAP sent
2017-03-11 17:25:46.920389 EDEN-V2[4170:1505942] Could not send device-id command: The operation couldn’t be completed. Socket is not connected
2017-03-11 17:25:46.920947 EDEN-V2[4170:1505942] Error sending public-key command to target: The operation couldn’t be completed. Socket is not connected
2017-03-11 17:25:46.921430 EDEN-V2[4170:1505942] Could not send scan-ap command: The operation couldn’t be completed. Socket is not connected
2017-03-11 17:25:46.921890 EDEN-V2[4170:1505942] Could not send set command: The operation couldn’t be completed. Socket is not connected
2017-03-11 17:25:46.922322 EDEN-V2[4170:1505942] configureAP sent

Also every time I log out in the Setup Controler I get this

  2017-03-11 21:04:24.904060 EDEN-V2[4311:1550807] -canOpenURL: failed for URL: "org-appextension-feature-password-management://" - error: "This app is not allowed to query for scheme org-appextension-feature-password-management"

It would be great to get some advice on how to fix my code

I now installed everything using carthage, but still it can't claim the device.
This is the new console output. It says several times there is a big problem with the socket. Unfortunatly I don't know how to fix this.

2017-03-12 17:16:52.780141 EDEN-V4[4620:1663820] [Accessibility] ****************** Loading GAX Client Bundle ****************
Organisation Name
Organisation Slug
Product Name
Product Slug
2017-03-12 17:16:57.350538 EDEN-V4[4620:1663820] spinner: <UIImage: 0x174090040>, {18, 18}
2017-03-12 17:17:02.582121 EDEN-V4[4620:1663820] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-03-12 17:17:02.589805 EDEN-V4[4620:1663820] [MC] Reading from public effective user settings.
2017-03-12 17:17:22.228198 EDEN-V4[4620:1663820] spinner: <UIImage: 0x170091800>, {18, 18}
2017-03-12 17:17:28.649121 EDEN-V4[4620:1663820] Cannot snapshot view (<UIKeyboardImpl: 0x10dd1fff0; frame = (0 0; 375 216); layer = <CALayer: 0x17002c040>>) with afterScreenUpdates:NO, because the view is not in a window. Use afterScreenUpdates:YES.
2017-03-12 17:17:45.947020 EDEN-V4[4620:1663820] DeviceID sent
2017-03-12 17:17:48.960933 EDEN-V4[4620:1663820] Could not send device-id command: Timeout occured while waiting for response from socket
2017-03-12 17:17:52.016313 EDEN-V4[4620:1663820] DeviceID sent
2017-03-12 17:17:52.118837 EDEN-V4[4620:1663820] DeviceID response received: 410037000a47353235303037
2017-03-12 17:17:52.119030 EDEN-V4[4620:1663820] PublicKey sent
2017-03-12 17:17:52.149419 EDEN-V4[4620:1663820] PublicKey response received
2017-03-12 17:17:52.149558 EDEN-V4[4620:1663820] ScanAP sent
2017-03-12 17:17:54.655415 EDEN-V4[4620:1663820] ScanAP response received
2017-03-12 17:17:55.912231 EDEN-V4[4620:1663820] button index 0
2017-03-12 17:17:55.912401 EDEN-V4[4620:1663820] Claim code - trying to set
2017-03-12 17:17:56.374898 EDEN-V4[4620:1663820] Device claim code set successfully: Fg7nv/HuGHSpyBPQl3r3TGTXOfEa8u5WkZsZULV7HHLuEpDYc7sdsT5/dv8Suuj
2017-03-12 17:17:56.455333 EDEN-V4[4620:1663820] spinner: <UIImage: 0x17409a040>, {18, 18}
2017-03-12 17:17:58.014684 EDEN-V4[4620:1663820] sparkSelectNetworkVC prepareForSegue : require_password
2017-03-12 17:17:58.586926 EDEN-V4[4620:1663820] Unbalanced calls to begin/end appearance transitions for <SparkSelectNetworkViewController: 0x10dda4960>.
2017-03-12 17:18:01.132330 EDEN-V4[4620:1663820] Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
2017-03-12 17:18:24.589778 EDEN-V4[4620:1663820] configureAP sent
2017-03-12 17:18:24.589969 EDEN-V4[4620:1663820] nextConnectionProgressState called, current state: 0
2017-03-12 17:18:39.186349 EDEN-V4[4620:1663820] nextConnectionProgressState called, current state: 1
2017-03-12 17:18:39.628851 EDEN-V4[4620:1663820] Could not send device-id command: The operation couldn’t be completed. Socket is not connected
2017-03-12 17:18:39.629398 EDEN-V4[4620:1663820] Error sending public-key command to target: The operation couldn’t be completed. Socket is not connected
2017-03-12 17:18:39.629820 EDEN-V4[4620:1663820] Could not send scan-ap command: The operation couldn’t be completed. Socket is not connected
2017-03-12 17:18:39.630484 EDEN-V4[4620:1663820] Could not send set command: The operation couldn’t be completed. Socket is not connected
2017-03-12 17:18:39.630893 EDEN-V4[4620:1663820] configureAP sent
2017-03-12 17:18:42.423570 EDEN-V4[4620:1665201] nextConnectionProgressState called, current state: 2
2017-03-12 17:18:42.435061 EDEN-V4[4620:1665201] nextConnectionProgressState called, current state: 3
Uknown setup error

I also tried it with a brand new Photon, but still the same socket problems :confused:

Hello,

Have you seen this thread? Ido, who’s the lead mobile engineer, mentions to:
You need to set your orgSlug and productSlug to the correct URL path components.
“My organisation slug” is not a valid slug - login to the dashboard and check your organization and product URL slug components and plug it in the source code, that should fix those errors.

If that doesn’t work he recommends making a support ticket and one of the tech support guys will help you.

Kyle