首页 > 解决方案 > Uber 的 API 还稳定吗?我无法获得基本身份验证工作 IOS 13 swift 5.0

问题描述

正在尝试对 Uber 的 IOS Ride Request SDK 进行基本集成,我按照此处的说明进行操作https://developer.uber.com/docs/riders/ride-requests/tutorials/api/ios

当尝试对用户进行身份验证时,它会打开 Uber 应用程序,然后立即返回到我的应用程序。控制台打印“code=25 '用户取消登录过程。'”我使用的是带有 IOS 13 和 Swift 5.0 的真实设备。看起来 Uber Developers 社交媒体自 2017 年以来就没有更新过,而且看起来也不是很活跃。

信息列表

<key>UberClientID</key>
    <string>907YWpr4cTwH9-TWVP0Fq8DX-_HuCxN3</string>
    <key>UberDisplayName</key>
    <string>Wandr</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>uber</string>
        <string>uberauth</string>
    </array>
    <key>UberCallbackURIs</key>
    <array>
        <dict>
            <key>UberCallbackURIType</key>
            <string>General</string>
            <key>URIString</key>
            <string>com.wandrinc.Wandr://oauth/consumer</string>
        </dict>
    </array>

登录功能

func loginToUber() {
        let loginManager = LoginManager()
        loginManager.login(requestedScopes:[.request], presentingViewController: UIApplication.shared.keyWindow?.rootViewController!, completion: { accessToken, error in
            if let error = error {
                print(error)
                return
            }
            self.requestRide()
        })
    }

应用代理

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
        let handledUberURL = UberAppDelegate.shared.application(app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplication.OpenURLOptionsKey.annotation] as Any)

        return handledUberURL
    }

    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        let handledUberURL = UberAppDelegate.shared.application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)

        return handledUberURL
    }

输出

Error Domain=com.uber.rides-ios-sdk.ridesAuthenticationError Code=25 "User cancelled the login process." UserInfo={NSLocalizedDescription=User cancelled the login process.}

标签: swiftapiauthenticationdeprecateduber-api

解决方案


推荐阅读