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

client.perform() never reaches onSuccess #20

Closed
kimaldis opened this issue Sep 17, 2018 · 9 comments
Closed

client.perform() never reaches onSuccess #20

kimaldis opened this issue Sep 17, 2018 · 9 comments
Labels

Comments

@kimaldis
Copy link

I've successfully managed to send an action to Bear (MacOS, note taking app) using the code below that appends text to a note but I'm struggling with return parameters. I should be getting not contents back but onSuccess never gets called. Any thoughts on what I may be missing?

	let manager =  Manager.shared
	manager.callbackURLScheme = "bear"

	let client = Client(urlScheme: "bear")

	do {
		try client.perform(
					action: "add-text",
					parameters: ["title": "BearNote", "text" : "some text", "mode" : "append" ],
					onSuccess: { parameters in  
                                                   // never gets here
						print( "Succeed" )
					},
					onFailure: { error in
						print( "Fail" )
					},
					onCancel: {
						print( "Cancelled" )
					}
			)
	} catch {
		print( "Error: \(error)" )
	}
@phimage
Copy link
Owner

phimage commented Sep 17, 2018

You must defined an url scheme for your app
https://github.com/phimage/CallbackURLKit#add-x-callback-url-support-to-your-app

let manager =  Manager.shared
manager.callbackURLScheme = "YOURappscheme" // not the client one ie. bear

why? because bear app will call your app using this scheme and onSuccess or onFailure or onCancel will be called

@kimaldis
Copy link
Author

Got it. That worked except I'm now I get an error;

  There is no application set to open the URL bearbar://x-callback-url/response?responseType=success&requestID=C09153F6-CA5F-4EA5-9781-935FB70AC168&title=BearNote&note=%23%20BearNote%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text%0Asome%20text&.

@phimage
Copy link
Owner

phimage commented Sep 17, 2018 via email

@kimaldis
Copy link
Author

isn't that what this does?

let manager =  Manager.shared
manager.callbackURLScheme = "bearbar"

@phimage
Copy link
Owner

phimage commented Sep 17, 2018

@kimaldis
Copy link
Author

Yes, I have:

	let manager =  Manager.shared
	manager.callbackURLScheme = "bearbar"
	manager.registerToURLEvent()

	manager["response"] = { parameters, success, failure, cancel in
		print( "response" )
	}

But I still get the 'no application set to open the URL' error

@phimage
Copy link
Owner

phimage commented Sep 17, 2018

I am talking about the image
image

this edit your info plist

@kimaldis
Copy link
Author

Got it working.

Thanks for your patience.

@phimage
Copy link
Owner

phimage commented Sep 17, 2018 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