Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login migration path for Swift Apps #129

Closed
perbrondum opened this issue Jun 6, 2021 · 6 comments
Closed

Login migration path for Swift Apps #129

perbrondum opened this issue Jun 6, 2021 · 6 comments
Assignees
Labels

Comments

@perbrondum
Copy link

perbrondum commented Jun 6, 2021

Can you please outline a migration path for existing Apps using salesforce.query()?

Looks like SwiftlySalesforce no longer needs the global salesforce variable.
Can we still use the following:

struct DB {
static let connectedApp: ConnectedApp = {
let consumerKey = "CONS KEY"
let callbackURL = URL(string: "CALL BACK")!
return ConnectedApp(consumerKey: consumerKey, callbackURL: callbackURL)
}()

static let salesforce: Salesforce = {
    return Salesforce(connectedApp: DB.connectedApp)
}()

}

and call is using: DB.salesforce.query()?

@mike4aday mike4aday self-assigned this Jun 6, 2021
@mike4aday
Copy link
Owner

@perbrondum - version 9 is designed to be more SwiftUI-friendly. It does away with the need for a global salesforce value, as you noted. And it doesn't have a Salesforce type, so the static variable you defined wouldn't compile.

If you create a file called Salesforce.json in your bundle and put the consumer key and callback URL there, you could create ConnectedApp wherever you need it, e.g. ConnectedApp().query(soql: "SELECT Id FROM Account"). (The no-arg constructor can throw if it doesn't find Salesforce.json in the bundle.)

Here's another example of creating ConnectedApp at the call site. This way you don't need a global salesforce variable, and you don't have to pass a reference between many SwiftUI views or in the SwiftUI environment.

@mike4aday
Copy link
Owner

@perbrondum I'll close this issue - please re-open if I didn't address your question.

@perbrondum
Copy link
Author

perbrondum commented Jun 7, 2021 via email

@perbrondum
Copy link
Author

perbrondum commented Jun 7, 2021 via email

@mike4aday
Copy link
Owner

@perbrondum the compiler just needs a hint about the type of value received, for example:

receiveValue: { (orgData: QueryResult<SalesforceRecord>) in

(And any errors thrown by ConnectedApp( ) have to be handled)

@perbrondum
Copy link
Author

perbrondum commented Jun 7, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants