Closed perbrondum closed 4 years ago
Hi @perbrondum. Your code works ok for me, so I'm not able to reproduce your results. See below. I have seen the 'cancelled' error when the user closes the Salesforce-hosted login screen without entering credentials.
import SwiftUI
import Combine
import SwiftlySalesforce
var subscriptions = Set<AnyCancellable>()
struct ContentView: View {
var body: some View {
Button(action: {
self.getLimits()
}) {
Text("Get Limits")
}
}
func getLimits() {
salesforce.limits().sink(receiveCompletion: { (completion) in
switch completion {
case .finished:
print("Finished limits query")
case let .failure(error) :
print(error)
}
}, receiveValue: { (limitResults: [String:Limit]) in
print(limitResults)
}).store(in: &subscriptions)
}
}
You're right. And now I can't reproduce it. Closed.
DB.salesforce.limits() .sink(receiveCompletion: { (completion) in switch completion { case .finished: print("Finished limits query") case let .failure(error) : print(error) } }, receiveValue: { (limitResults: [String:Limit]) in print(limitResults) }).store(in: &subscriptions)
alone (with a preceding login, fails w: -999 (missing UserInfo). 2020-04-02 21:18:46.092831+0200 testComb[19823:1760466] Task <86442BB7-2523-4325-AAD4-991B19C63CA5>.<3> finished with error [-999] Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://na84.salesforce.com/services/data/v47.0/limits, NSLocalizedDescription=cancelled, NSErrorFailingURLKey=https://na84.salesforce.com/services/data/v47.0/limits}
But w identity() added to call:, var subscriptions = Set()
DB.salesforce.identity().sink(receiveCompletion: { (completion) in
switch completion {
case .finished:
print("Logged in")
case let .failure(error) :
print("Failed to login. Error: (error)")
}
}) { identity in
DB.salesforce.limits()
.sink(receiveCompletion: { (completion) in
switch completion {
case .finished:
print("Finished limits query")
case let .failure(error) :
print(error)
}
}, receiveValue: { (limitResults: [String:Limit]) in
print(limitResults)
}).store(in: &subscriptions)
}.store(in: &subscriptions)
}
it works. The old limits() used to leverage the userinfo somehow, or why did it work previously?