-
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
New login steps #114
Labels
Comments
Hi @perbrondum - you have to assign the result of |
@perbrondum try this: let subscription = salesforce.identity().sink(receiveCompletion: { (completion) in
//TODO:
}) { identity in
//TODO
} |
@perbrondum or this variation: var subscriptions = Set<AnyCancellable>()
// ...
salesforce.identity().sink(receiveCompletion: { (completion) in
//TODO:
}) { identity in
//TODO
}.store(in: &subscriptions) |
I had something similar (below). Neither brings up the dialog. I have
reset the simulator and changed my setup to match yours. Still no dialog...
Scene (Willconnectto):
*let* consumerKey = "3MVG9szVa2...."
*let* callbackURL = URL(string: "opportunityforce://authorized")!
*let* connectedApp = ConnectedApp(consumerKey: consumerKey,
callbackURL: callbackURL)
salesforce = Salesforce(connectedApp: connectedApp)
ViewDidLoad()
* var* subscriptions = Set<AnyCancellable>()
* let* sfdc = Util.salesforce
*let* pub = sfdc.identity()
pub.sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print(error)
*case* .finished:
print("Finished")
*break*
}
}, receiveValue: { identity *in*
print("Logged on as \(identity.username)")
})
.store(in: &subscriptions)
*let* soql = "select id, name from account"
*let* pub2 = sfdc.query(soql: soql)
pub2.sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print(error)
*case* .finished:
*break*
}
}, receiveValue: { queryResult *in*
print(queryResult.records)
})
.store(in: &subscriptions)
Per B Jakobsen
CEO Tap2Sales.com
…On Sun, Mar 29, 2020 at 7:09 PM Michael Epstein ***@***.***> wrote:
@perbrondum <https://github.com/perbrondum> or this variation:
var subscriptions = Set<AnyCancellable>()// ...salesforce.identity().sink(receiveCompletion: { (completion) in
//TODO:}) { identity in
//TODO}.store(in: &subscriptions)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#114 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALCYWDCSZ44DGBA3XGEJNADRJ56F7ANCNFSM4LWATFXQ>
.
|
Got it. Moved your snippet to DidAppear() and now it works.
Thanks,
Per B Jakobsen
CEO Tap2Sales.com
[email protected]
new Phone# (415) 850 0016
old Phone# (702) 416 7959
…On Sun, Mar 29, 2020 at 7:51 PM Per Jakobsen ***@***.***> wrote:
I had something similar (below). Neither brings up the dialog. I have
reset the simulator and changed my setup to match yours. Still no dialog...
Scene (Willconnectto):
*let* consumerKey = "3MVG9szVa2...."
*let* callbackURL = URL(string: "opportunityforce://authorized")!
*let* connectedApp = ConnectedApp(consumerKey: consumerKey,
callbackURL: callbackURL)
salesforce = Salesforce(connectedApp: connectedApp)
ViewDidLoad()
* var* subscriptions = Set<AnyCancellable>()
* let* sfdc = Util.salesforce
*let* pub = sfdc.identity()
pub.sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print(error)
*case* .finished:
print("Finished")
*break*
}
}, receiveValue: { identity *in*
print("Logged on as \(identity.username)")
})
.store(in: &subscriptions)
*let* soql = "select id, name from account"
*let* pub2 = sfdc.query(soql: soql)
pub2.sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print(error)
*case* .finished:
*break*
}
}, receiveValue: { queryResult *in*
print(queryResult.records)
})
.store(in: &subscriptions)
Per B Jakobsen
CEO Tap2Sales.com
On Sun, Mar 29, 2020 at 7:09 PM Michael Epstein ***@***.***>
wrote:
> @perbrondum <https://github.com/perbrondum> or this variation:
>
> var subscriptions = Set<AnyCancellable>()// ...salesforce.identity().sink(receiveCompletion: { (completion) in
> //TODO:}) { identity in
> //TODO}.store(in: &subscriptions)
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#114 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ALCYWDCSZ44DGBA3XGEJNADRJ56F7ANCNFSM4LWATFXQ>
> .
>
|
Thanks for your help, and thanks for all you're doing for
SwiftlySalesforce. Moving away from PromiseKit was a great idea. The code
is so much cleaner. I wrote two routines to illustrate the new way and
to guide our transition. I believe an example like the below would be
useful for people not used to Combine.
*private* *func* getSFDCDataSequence() {
*var* subscriptions = Set<AnyCancellable>()
*var* inClause = "('"
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*
print("Logged in as \(identity.displayName)")
*let* sfdc = DB.salesforce
*let* soql = "select id, name from account where ownerId = '
\(identity.userID)'"
*let* pub = sfdc.query(soql: soql)
pub.sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print("Failed to query SFDC. Error: \(error)")
*case* .finished:
print("Completed Account Data Retrieval")
}
}, receiveValue: { accountData *in*
*for* rows *in* accountData.records {
*let* aId = rows.string(forField: "Id")!
inClause += aId + "' , '"
print(rows.string(forField: "Name")!)
}
inClause = String(inClause.dropLast(3))
inClause += ")"
*let* soql = "select id, name from contact where accountId
in \(inClause) and ownerId = '\(identity.userID)'"
*let* pub = sfdc.query(soql: soql)
pub.sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print("Failed to query SFDC. Error: \(error)")
*case* .finished:
print("Completed Contact Data Retrieval")
}
}, receiveValue: { contactData *in*
*for* rows *in* contactData.records {
print(rows.string(forField: "Name")!)
}
}).store(in: &subscriptions)
}).store(in: &subscriptions)
}.store(in: &subscriptions)
}
*private* *func* getSFDCDataParallel() {
*var* subscriptions = Set<AnyCancellable>()
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*
*let* eventSoql = "SELECT id from event limit 1"
*let* contactSoql = "SELECT id from contact limit 1"
*let* events = DB.salesforce.query(soql: eventSoql)
*let* contacts = DB.salesforce.query(soql: contactSoql)
events.zip(contacts).sink(receiveCompletion: { (completion) *in*
*switch* completion {
*case* *let* .failure(error):
print(error)
*case* .finished:
print("Completed 1,2 queries")
}
}) { (events, contacts) *in*
*let* eventId = events.records.first?.string(forField: "Id")
*let* eventWhoId = contacts.records.first?.string(forField:
"Id")
*let* members = DB.salesforce.query(soql: "SELECT id,
lastname, firstname, email, name, mobilePhone from contact where id in
(select relationId FROM EventRelation WHERE EventId = '\(eventId!)')")
*let* campaign = DB.salesforce.query(soql: "SELECT
Id, Description,EndDate,IsActive,Name,StartDate,Status,Type FROM Campaign
where isactive = true and status = 'In Progress' and endDate > TODAY order
by StartDate, Name")
*let* whoId = DB.salesforce.query(soql: "SELECT
id, lastname, firstname, email, name, mobilePhone from contact where id = '
\(eventWhoId!)'")
campaign.zip(members, whoId).sink(receiveCompletion: {
(completion) *in*
*switch* completion {
*case* *let* .failure(error):
print(error)
*case* .finished:
print("Completed 3, 4, 5 queries")
}
}) { (campaign, members, contacts) *in*
*let* campaigns = campaign.records
*let* members = members.records
*let* contacts = contacts.records
*for* campaign *in* campaigns {
print(campaign.string(forField: "Name")!)
}
*for* member *in* members {
print(member.string(forField: "Name")!)
}
*for* contact *in* contacts {
print(contact.string(forField: "Name")!)
}
}.store(in: &subscriptions)
}.store(in: &subscriptions)
}.store(in: &subscriptions)
}
…On Sun, Mar 29, 2020 at 7:58 PM Per Jakobsen ***@***.***> wrote:
Got it. Moved your snippet to DidAppear() and now it works.
Thanks,
Per B Jakobsen
CEO Tap2Sales.com
***@***.***
new Phone# (415) 850 0016
old Phone# (702) 416 7959
On Sun, Mar 29, 2020 at 7:51 PM Per Jakobsen ***@***.***> wrote:
> I had something similar (below). Neither brings up the dialog. I have
> reset the simulator and changed my setup to match yours. Still no dialog...
>
> Scene (Willconnectto):
>
> *let* consumerKey = "3MVG9szVa2...."
>
> *let* callbackURL = URL(string: "opportunityforce://authorized")!
>
> *let* connectedApp = ConnectedApp(consumerKey: consumerKey,
> callbackURL: callbackURL)
>
> salesforce = Salesforce(connectedApp: connectedApp)
>
> ViewDidLoad()
>
> * var* subscriptions = Set<AnyCancellable>()
>
> * let* sfdc = Util.salesforce
>
> *let* pub = sfdc.identity()
>
> pub.sink(receiveCompletion: { (completion) *in*
>
> *switch* completion {
>
> *case* *let* .failure(error):
>
> print(error)
>
> *case* .finished:
>
> print("Finished")
>
> *break*
>
> }
>
> }, receiveValue: { identity *in*
>
> print("Logged on as \(identity.username)")
>
> })
>
> .store(in: &subscriptions)
>
>
>
> *let* soql = "select id, name from account"
>
> *let* pub2 = sfdc.query(soql: soql)
>
> pub2.sink(receiveCompletion: { (completion) *in*
>
> *switch* completion {
>
> *case* *let* .failure(error):
>
> print(error)
>
> *case* .finished:
>
> *break*
>
> }
>
> }, receiveValue: { queryResult *in*
>
> print(queryResult.records)
>
> })
>
> .store(in: &subscriptions)
>
>
> Per B Jakobsen
> CEO Tap2Sales.com
>
>
> On Sun, Mar 29, 2020 at 7:09 PM Michael Epstein ***@***.***>
> wrote:
>
>> @perbrondum <https://github.com/perbrondum> or this variation:
>>
>> var subscriptions = Set<AnyCancellable>()// ...salesforce.identity().sink(receiveCompletion: { (completion) in
>> //TODO:}) { identity in
>> //TODO}.store(in: &subscriptions)
>>
>> —
>> You are receiving this because you were mentioned.
>> Reply to this email directly, view it on GitHub
>> <#114 (comment)>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/ALCYWDCSZ44DGBA3XGEJNADRJ56F7ANCNFSM4LWATFXQ>
>> .
>>
>
|
Thank you @perbrondum |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm surely missing something. Can't get a login screen to appear. The basic:
let consumerKey = "3MVG..."
let callbackURL = URL(string: "opportunityforce://authorized")!
let connectedApp = ConnectedApp(consumerKey: consumerKey, callbackURL: callbackURL)
salesforce = try? Salesforce(consumerKey: consumerKey, callbackURL: callbackURL)
salesforce.identity()
normally brings up the login screen, but not anymore...
Could you please provide a simplel login example?
The text was updated successfully, but these errors were encountered: