mike4aday / SwiftlySalesforce

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

Remove cancel button login #152

Closed chaitba2 closed 10 months ago

chaitba2 commented 10 months ago

Hi,

I used your library to integrate Salesforce into my app. It is easy to use and very helpful.

I would like to remove the cancel button from the Login widget. And am not able to find a way to remove it. Could you please point me in the direction where I can achieve this implementation?

Also is there a way to bypass login alert?

Thanks in advance.,

mike4aday commented 10 months ago

Hi @chaitba2. To the best of my knowledge, it's not possible to remove the "Cancel" button from the top left of Apple's presented authentication view. Swiftly Salesforce users ASWebAuthenticationSession and there isn't a configuration parameter to hide the "Cancel" button -- which may be for the best, since there needs to be a way for the user to dismiss the modal.

Swiftly Salesforce will return a cancellation error if the user does tap "Cancel" - that is, you can detect the difference between the user canceling the Salesforce authentication vs. failing to authenticate.

mike4aday commented 10 months ago

@chaitba2 I will mark this issue as 'closed' but if I didn't answer your question, please reopen.

mike4aday commented 10 months ago

@chaitba2 I realized I forgot to address your second question: "Also is there a way to bypass login alert?" -- I'll reopen the issue now.

Please elaborate on what you mean by "bypass"? What are you trying to accomplish? Do you want to authenticate to Salesforce with a different OAuth flow, e.g. username-password flow (which is not recommended)? Or are you trying to have Swiftly Salesforce not display the login form when the user's session has expired and your app makes a call to Salesforce?

chaitba2 commented 10 months ago

I want to skip the alert and go directly to the login page. Attached the screenshot of alert. I tried the following to skip the alert,

in WebAuthenticationSession class, changed the below line from false to true session.prefersEphemeralWebBrowserSession = true

and to display login again using the following code with delay

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
    Task {
        await login()
     }
})

Please correct me if am wrong.

Simulator Screenshot - iPad Pro (12 9-inch) (6th generation) (16GB) - 2023-12-05 at 10 03 05

mike4aday commented 10 months ago

@chaitba2 personally I don't like to rely on the delay and I find it hard to 'reason' about what else is going on during that delay. Does it work for you? Why do you not want the alert to display? IMO the alert is common in iOS apps so users aren't put off by it and the code is cleaner.