Esri / data-collection-ios

Mobile data collection app using the iOS Runtime SDK.
https://developers.arcgis.com/
Apache License 2.0
25 stars 26 forks source link

App Crashes on Login #303

Open userFortyTwo opened 3 years ago

userFortyTwo commented 3 years ago

When hitting the profile button and choosing "Sign In", the app immediately crashes on my iPhone X (MQAC2ZD/A) running iOS 14.6 (18F72) with the following output appearing in the console:

[Portal Session Manager] 
    Loading Portal - https://www.arcgis.com
2021-06-11 11:33:40.286813+0200 data-collection[10305:555925] [AuthenticationSession] The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".
2021-06-11 11:33:40.287354+0200 data-collection[10305:555925] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'
*** First throw call stack:
(0x1ad02f298 0x1c0d89480 0x1dcdce4cc 0x10565fa04 0x10565f2a8 0x105769700 0x11b183ae8 0x11b18532c 0x11b19376c 0x1acfae2e0 0x1acfa8740 0x1acfa7818 0x1c36ad570 0x1af8d30e8 0x1af8d8664 0x1048575e4 0x1acc86140)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'
terminating with uncaught exception of type NSException

I am using an exact clone of the latest version of the data collection app (commit 437f6f5, May 8, 2021) without any modifications made to the source code. The only additional steps I have performed are registering an OAuth application in the ArcGIS Developer Dashboard with a data-collection://auth redirect URL and configuring its client ID in the data-collection-ios/data-collection/.secrets file (ARCGIS_CLIENT_ID=…), as described in the README. The app was built using Xcode 12.5 (12E262) on macOS 11.4 (20F71).

screenshot

When performing the same steps in the iPad simulator, I get an additional stack trace:

[Portal Session Manager] 
    Loading Portal - https://www.arcgis.com
2021-06-11 11:36:30.002717+0200 data-collection[13325:405636] [AuthenticationSession] The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".
2021-06-11 11:36:30.008923+0200 data-collection[13325:405636] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff20422fba __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007fff20193ff5 objc_exception_throw + 48
    2   AuthenticationServices              0x00007fff4aae1b15 -[ASWebAuthenticationSession initWithURL:callbackURLScheme:usingEphemeralSession:completionHandler:] + 684
    3   ArcGIS                              0x0000000107bb84bc -[AGSOAuthChallengeHandler loginWithCompletion:] + 1373
    4   ArcGIS                              0x0000000107bb7d33 -[AGSOAuthChallengeHandler handleChallenge:] + 288
    5   ArcGIS                              0x0000000107cbd6f3 -[AGSAuthenticationChallenge continueWithDefaultHandling] + 743
    6   libdispatch.dylib                   0x000000010f71c578 _dispatch_call_block_and_release + 12
    7   libdispatch.dylib                   0x000000010f71d74e _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x000000010f72bb3f _dispatch_main_queue_callback_4CF + 1152
    9   CoreFoundation                      0x00007fff203908f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    10  CoreFoundation                      0x00007fff2038b169 __CFRunLoopRun + 2781
    11  CoreFoundation                      0x00007fff2038a1a7 CFRunLoopRunSpecific + 567
    12  GraphicsServices                    0x00007fff2b874d85 GSEventRunModal + 139
    13  UIKitCore                           0x00007fff246c14df -[UIApplication _run] + 912
    14  UIKitCore                           0x00007fff246c639c UIApplicationMain + 101
    15  data-collection                     0x00000001070ed10b main + 75
    16  libdyld.dylib                       0x00007fff2025abbd start + 1
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The provided scheme is not valid. A scheme should not include special characters such as ":" or "/".'
terminating with uncaught exception of type NSException
CoreSimulator 757.5 - Device: iPad Pro (9.7-inch) (03A962BB-3C25-4E7F-B884-6E96ABA91459) - Runtime: iOS 14.5 (18E182) - DeviceType: iPad Pro (9.7-inch)

I have tried modifying the basePortalDomain and webMapItemID in AppConfiguration.swift to point to a custom web map. Since this is not a public web map, I then get a prompt upon app launch asking me to sign in to access the resource. When hitting the "Sign in" button on that prompt, the app crashes with the same error message.

I do not see what's wrong here. The URL scheme is correctly configured in all AppConfiguration.swift, Info.plist and the dashboard, so I'm suggesting that this is a bug.

enum OAuthConfig {
    /// The App's oAuth redirect URL.
    /// - The URL must match the path created in the **Current Redirect URIs** section of the **Authentication** tab within the [Dashboard of the ArcGIS for Developers site](https://developers.arcgis.com/applications).
    static let redirectUrl = "data-collection://auth"
}
<dict>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>com.esri.arcgisruntime.exampleapps.data-collection</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>data-collection</string>
            </array>
        </dict>
    </array>
    …
</dict>
mhdostal commented 3 years ago

@userFortyTwo - This issue resulted from a change in iOS 14.5 where previously-allowed redirect URLs now cause an error. We discovered this error shortly after the release of 14.5 and have patched the Runtime SDK for iOS to fix the issue. Downloading and building with the v100.11.1 version of the SDK should resolve your problem.

Thank you for using Data Collection!