Can you help me with this?

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

  1. Please only ask a question once in one place.  This is a rule of the forums.
     
  2. You’re asking us to code for you.  You need to help us to help you.
     
    a. Please zip up your sample project.
    b. Upload it to a free file sharing location.
    c. Provide a link to the code here in the forums.
     
  • OR -  If your code sample is short
     
    a. Paste it here using appropriate legibility formatting.
    formatyourcode.jpg

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?

  1. Please only ask a question once in one place.  This is a rule of the forums.
     
  2. You’re asking us to code for you.  You need to help us to help you.
     
    a. Please zip up your sample project.
    b. Upload it to a free file sharing location.
    c. Provide a link to the code here in the forums.
     
  • OR -  If your code sample is short
     
    a. Paste it here using appropriate legibility formatting.
    formatyourcode.jpg

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?