-
Notifications
You must be signed in to change notification settings - Fork 43
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
Comments
@perbrondum - version 9 is designed to be more SwiftUI-friendly. It does away with the need for a global If you create a file called Here's another example of creating |
@perbrondum I'll close this issue - please re-open if I didn't address your question. |
I actually tried using ConnectedApp():
ConnectedApp().query(soql: “Select ID from account”)
But in my case it fails with 'Generic parameter 'T' could not be inferred’
Per B Jakobsen
CEO Tap2Sales.com
***@***.***
…On Jun 7, 2021 at 2:04:59 AM, Michael Epstein ***@***.***> wrote:
@perbrondum <https://github.com/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
<https://github.com/mike4aday/MySalesforceAccounts/blob/2fa839ad30155d384712c3b155dddb2ed19119b8/MySalesforceAccounts/MyAccountsLoader.swift#L23>
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.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#129 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALCYWDDZHSENHMLNNATVUMLTRQEKXANCNFSM46GLANHA>
.
|
Or in the original context:
*var* subscriptions = Set<AnyCancellable>()
ConnectedApp().query(soql: "SELECT Id FROM Account", allowsLogin:
*true*).sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print("Failed to execute 2 queries in insert content, Error
: \(error)")
*case* .finished:
print("Completed 2 queries in insert content")
}
}, receiveValue: { orgData *in*
//
}).store(in: &subscriptions)
Still returns : ‘Generic parameter ’T’ could not be inferred’
Obviously I’m doing something wrong here but I’m trying to access impact on
our existing App.
Per B Jakobsen
CEO Tap2Sales.com
***@***.***
…On Jun 7, 2021 at 2:08:21 PM, Per Jakobsen ***@***.***> wrote:
I actually tried using ConnectedApp():
ConnectedApp().query(soql: “Select ID from account”)
But in my case it fails with 'Generic parameter 'T' could not be inferred’
Per B Jakobsen
CEO Tap2Sales.com
***@***.***
On Jun 7, 2021 at 2:04:59 AM, Michael Epstein ***@***.***>
wrote:
> @perbrondum <https://github.com/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
> <https://github.com/mike4aday/MySalesforceAccounts/blob/2fa839ad30155d384712c3b155dddb2ed19119b8/MySalesforceAccounts/MyAccountsLoader.swift#L23>
> 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.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#129 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ALCYWDDZHSENHMLNNATVUMLTRQEKXANCNFSM46GLANHA>
> .
>
|
@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 |
Thank you.
*var* subscriptions = Set<AnyCancellable>()
*do* {
*try*? ConnectedApp().query(soql: "SELECT Id FROM Account",
allowsLogin: *true*).sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print("Failed to execute query in insert content, Error
: \(error)")
*case* .finished:
print("Completed query")
}
}, receiveValue: { (orgData: QueryResult<SalesforceRecord>)
*in*
}).store(in: &subscriptions)
}
Per B Jakobsen
CEO Tap2Sales.com
***@***.***
…On Jun 7, 2021 at 5:29:23 PM, Michael Epstein ***@***.***> wrote:
@perbrondum <https://github.com/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)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#129 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALCYWDGJBLAKM6QGXTUTBATTRTQVHANCNFSM46GLANHA>
.
|
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)
}()
}
and call is using: DB.salesforce.query()?
The text was updated successfully, but these errors were encountered: