Home > OS >  Connecting to the Secure Content in IOS
Connecting to the Secure Content in IOS

Time:10-26

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

CodePudding user response:

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

CodePudding user response:

You can achieve this by using the following code, after that no popup appears asking for user credentials

self.portal = AGSPortal(url: URL(string: "https://geoportal.mycompany.com")!, loginRequired: false)

self.portal.credential = AGSCredential(user: "username", password: "password")
  • Related