mike4aday / SwiftlySalesforce

The Swift-est way to build native mobile apps that connect to Salesforce.
MIT License
136 stars 43 forks source link

Login not working after dismissed #124

Closed auctifera-josed closed 3 years ago

auctifera-josed commented 4 years ago

Hi everyone, some users are experiencing an issue with the login if they dismissed it by tapping outside the view controller (if they tap in the cancel button there is no problem)

We have a "Log in" button that calls the following code

salesforce.identity(config: .shared)
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: { (uCompletion) in
    ///stuff
}, receiveValue: { (userInfo : Identity) in
    ///stuff
}).store(in: &cancellables)

Then the salesforce login is presented in a modal which works fine, but if the user taps outside the modal the login modal is dismissed and there is no way of presenting the login view again

IMG_210C282AA8A6-1

I thought that maybe canceling the cancelable would help but it didn't

var loginCancelable: AnyCancellable?

func login(){
    if let loginCancelable = loginCancelable {
        loginCancelable.cancel()
    }

    loginCancelable = salesforce.identity(config: config)
    ...
}

Even tried reinitializing the salesforce property before calling the identity

...
salesforce = Salesforce(connectedApp: connectedApp, oAuthHostname: oauthHostName)
loginCancelable = salesforce.identity(config: config)
...

Does anyone have an idea what's going on here? Or maybe just how can we present the login modal in full screen so they can't tap outside?

mike4aday commented 4 years ago

@auctifera-josed - I did try to capture the tap outside the login form gesture, but didn't succeed. Seems to be a limitation of Apple's prescribed authentication mechanism using ASWebAuthenticationSession.

Another idea I had but haven't had time yet to prototype: Salesforce allows you to specify a different form factor for the login form - see the display parameter at this link. Swiftly Salesforce currently uses touch -- maybe page offers a larger display which, if accommodated by ASWebAuthenticationSession, would make it less likely that the user clicks outside the bounds of the login form?