-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Two way communication #12
Comments
Using closure on one side to receive response And on the other side by calling success(with param or not) or failure(with error) or cancel |
@phimage so do I need to declare a new manager instance in my client class to handle incoming callbacks? |
one manager by app, you can use the default one |
@phimage ok, I don't exactly understand closures with on* operations I have Client class with a method that does call. try self.perform(action: "runOperation", parameters: parameters, onSuccess: { parameters in
}, onFailure: nil, onCancel: nil) How do I pass sourceapp://x-callback-url/acceptTranslation on x-success? |
did you need to know how to do it exactly or just fulfil a need to interact with two of your applications? The framework do it automatically but use sourceapp://x-callback-url/response/ for error or success and pass an ID to retrieve the code to execute in callback And in closure you can execute the code that could be call in an action called "acceptTranslation" I can add parameters to implement such behaviour if I have time... |
@phimage https://github.com/phimage/CallbackURLKit/blob/master/Sources/Manager.swift#L197 |
Yes this is the code We could add an 'Action'(string) by callback type and change here the URL if this action is specified |
@phimage hm.. Can't I just set it as one of the params? let parameters = [
"x-succes": "sourceapp://x-callback-url/acceptTranslation"
] |
@phimage additionally I am adding this plugin to the ObjectiveC app, and app delegate is actually in obj-c, and I can figure out how to add Manager.shared to pass it url handling |
yes you can try to put this as parameters, never tried... I expect that I do not filter it for obj-c I never tried if there is some incompatibility
|
@phimage Setting as parameter works. I am working on Objective-c event binding to swift. I found this is how they do it in https://github.com/aerogear/aerogear-cordova-oauth2/ Here they are catching call https://github.com/aerogear/aerogear-cordova-oauth2/blob/master/src/ios/AppDelegate%2Burl.m#L36 which calls notification event and here is the handler for event https://github.com/aerogear/aerogear-cordova-oauth2/blob/master/src/ios/oauth-0.4.0/OAuth2Module.swift#L92 |
with swizzle they try to achieve this automatically but it's not mandatory |
How would you implement two way communication described in http://x-callback-url.com/examples/
Something like:
The text was updated successfully, but these errors were encountered: