mike4aday / SwiftlySalesforce

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

Need to add a custom bar button item to a SFSafariViewController that is generated programmatically #68

Closed jbergandino closed 6 years ago

jbergandino commented 6 years ago

I've built a business card scanner app that gives users the option to sync with SalesForce and automatically create contacts. Since not all users use SalesForce, but some may still click my "Log into SalesForce" button, I need a way for users to back out of the login screen.

Upon initial login screen load, Swiftly Salesforce replaces the current rootViewController with a SFSafariViewController programmatically, so I can't easily add a "Cancel" bar-button-item via the main storyboard. Also, this replacement logic currently lives within the Pod itself in the LoginDelegate, so I can't easily pass in button generation code/logic. I'm thinking I may need to build an extension to the login delegate that overrides that logic so I can inject button generation code/logic, but I feel like there is a simpler solution. After all, I'm really just trying to dismiss a view via a button.

Any thoughts are appreciated.

mike4aday commented 6 years ago

@JB775 you could implement a custom login flow and view by implementing the LoginViewController protocol, but I agree with you, it's too much work just to gain a usable 'dismiss' button. I've thought about this recently, and in retrospect I should have presented the Safari login view controller, rather than having it replace the root window when logging in.

If you can wait ~1-2 weeks, I'll update the framework so that it presents the Safari view controller, and the dismiss button would work as expected. It should be straightforward, but I have to make sure that dismissing the window is handled properly in the promise chain.

jbergandino commented 6 years ago

Sounds good, I'll keep an eye out for the update. I have enough new feature dev work I'd rather focus on if you are working on a fix within a few weeks.

In the meantime, I may size-down and wrap that view inside a container view and add an external button that routes users back to the previous viewController. A little hacky but that way my users aren't stuck until they force-close the app.

mike4aday commented 6 years ago

@JB775 the implementation I'm working on requires some breaking changes so I need to put them in the next major release (per semantic versioning guidelines), and I need more time. I'll let you know once it's ready.

jbergandino commented 6 years ago

@mike4aday No worries, thanks for the heads up.

mike4aday commented 6 years ago

@JB775 will be implemented in version 7 - in the works. Thanks.

mike4aday commented 6 years ago

@JB775 delivered in version 7.0.0. There's now a dismissible Safari login controller - it will throw an error if the user dismisses it, which your code should handle if necessary.

jbergandino commented 5 years ago

Thanks!