0

I am trying to connect to the portal object with the authenticated user which is cached and used throughout the app session, to provide the app with a view of a portal that is centered around a single user.

When the app is restarted, the credential must be reinstated, or the user must repeat the authentication process.

But every time when I connect it asks for username and password, I actually want to embed that into the code.

Any workarounds?

Below is my code.

self.portal = AGSPortal(url: URL(string: "https://www.arcgis.com")!, loginRequired: false)
self.portal.credential = AGSCredential(user: "theUser", password: "thePassword")
 self.portal.load() {[weak self] (error) in
    if let error = error {
        print(error)
        return
    }
       
    if self?.portal.loadStatus == AGSLoadStatus.loaded {
        let fullName = self?.portal.user?.fullName
        print(fullName!)
    }
}

1 Answer 1

1

You can use AGSCredentialCache's enableAutoSyncToKeychainWithIdentifier:accessGroup:acrossDevices:accessible: to store credentials in the Keychain and when you re-launch the app, it won't prompt again. Please call this function at the start of the application using AGSAuthenticationManager.shared().credentialCache.

Regards, Nimesh

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.