Hello.
I want to get web viewer’s event.
Please check this url.
https://docs.coronalabs.com/api/library/native/newWebView.html
As you know, this is about web viewer.
With webView:addEventListener( “urlRequest”, webListener ), it works well in Android, but in iOS it doesn’t work.
I think eventListener doesn’t work in iOS.
Please help me with this.
Thank you.
Jacky
Tip in this case, providing the sample project is best because we’ll want to see your build.settings too.
@Jacky this works fine in iOS for me so you will need to post an error or something to work with here.
Hello, there.
Thank you for all of your reply.
And this is the source code with build.settings.
– main.lua
local function webListener( event ) if(event.url == "http://www.123contactform.com/thank-you-2675144.html" and event.type == "loaded") then composer.removeAll() webView:removeSelf() local options = { effect = "fade", time = 400, params = { sampleVar1 = "my sample variable", sampleVar2 = "another sample variable" } } composer.gotoScene("signup\_cong", options); end end -- Called when the scene's view does not exist: function scene:create( event ) group = self.view bgImage = display.newImageRect("pages/signup2.png",display.contentWidth, display.contentHeight) bgImage.x = display.contentWidth/2 bgImage.y = display.contentHeight/2 group:insert(bgImage) webView = native.newWebView( display.contentWidth/2, display.contentHeight/2 + 30, 300, 280 ) webView:request( "http://www.123contactform.com/form-2675144/Survey-Form") webView:addEventListener( "urlRequest", webListener ) nextButton = display.newImageRect("no.png",40, 40) nextButton.x = 45 nextButton.y = display.contentHeight - 45 group:insert(nextButton) nextButton:addEventListener("tap", closeSplash) end
As I mentioned, the code worked well in Android.
But when I run in iOS, it doesn’t work-in other words, the app can’t capture event of successfully loading url.
Please help me.
Quick answer is best.
Great regards.
Jacky
Saying “it doesn’t work” is not good enough… You need to scope why it doesn’t work, error messages etc.
Have printed the event parameter in webListener to see what is returned or if anything is actually returned?
Tip in this case, providing the sample project is best because we’ll want to see your build.settings too.
@Jacky this works fine in iOS for me so you will need to post an error or something to work with here.
Hello, there.
Thank you for all of your reply.
And this is the source code with build.settings.
– main.lua
local function webListener( event ) if(event.url == "http://www.123contactform.com/thank-you-2675144.html" and event.type == "loaded") then composer.removeAll() webView:removeSelf() local options = { effect = "fade", time = 400, params = { sampleVar1 = "my sample variable", sampleVar2 = "another sample variable" } } composer.gotoScene("signup\_cong", options); end end -- Called when the scene's view does not exist: function scene:create( event ) group = self.view bgImage = display.newImageRect("pages/signup2.png",display.contentWidth, display.contentHeight) bgImage.x = display.contentWidth/2 bgImage.y = display.contentHeight/2 group:insert(bgImage) webView = native.newWebView( display.contentWidth/2, display.contentHeight/2 + 30, 300, 280 ) webView:request( "http://www.123contactform.com/form-2675144/Survey-Form") webView:addEventListener( "urlRequest", webListener ) nextButton = display.newImageRect("no.png",40, 40) nextButton.x = 45 nextButton.y = display.contentHeight - 45 group:insert(nextButton) nextButton:addEventListener("tap", closeSplash) end
As I mentioned, the code worked well in Android.
But when I run in iOS, it doesn’t work-in other words, the app can’t capture event of successfully loading url.
Please help me.
Quick answer is best.
Great regards.
Jacky
Saying “it doesn’t work” is not good enough… You need to scope why it doesn’t work, error messages etc.
Have printed the event parameter in webListener to see what is returned or if anything is actually returned?