Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to send parameters to web app through webView.
Started by fazilreyaz Feb 18 2019 12:16 PM

6 replies to this topic
webview location web event parameters

Best Answer fazilreyaz , 19 February 2019 - 12:48 AM

Okay I did it. I captured the event.url and stopped the request and requested new url with location parameters and performed the same operation on that url.

 

Thanks,

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

fazilreyaz

[GLOBAL: userInfoPane.html]
fazilreyaz
  • Enthusiast

  • 67 posts
  • Corona SDK

Hello Everyone,

 

I have an app that in part, uses a webview to display an existing web application. There are multiple pages in that web app. What I want is when a user visits a particular page. e.g: there are three pages. 1. Home.  2. Services. 3.Contact

 

If a user clicks on the third link inside the webView, I want to send some data from corona to webView and perform some operation on that data in my web app.

 

 

 

Is there any possible way to do it?

 

Actually I want to send user location to my web portal only if he clicks some specific links inside the web View.

 

 

 

 

Please any help would be highly appreciated.

@RobMiracle maybe you can have a look and help me out...

 

 

Thanks,



[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,013 posts
  • Corona SDK

You can send the location as part of the get parameter when you load the page. Something like home.html?lat=xxx&long=xxxx. I don't know of a way to send value after the page is loaded.



[TOPIC: post.html]
#3

fazilreyaz

[GLOBAL: userInfoPane.html]
fazilreyaz
  • Enthusiast

  • 67 posts
  • Corona SDK

You can send the location as part of the get parameter when you load the page. Something like home.html?lat=xxx&long=xxxx. I don't know of a way to send value after the page is loaded.

 

I cannot send the parameters at the beginning. 

 

 

I did it but it's neither efficient nor reliable.

function webListenerForBrowsers( event )
    if event.url then     
     if(event.url == "http://app.example.com/distributors/Coupons.aspx") then
         --locations.body = "lat=1234"
         --network.request("https://app.example.com/Distributors/SetSession.aspx", "POST", emailNetworkListener, locations)          
         if xVal == 0 then
            xVal = 1
            webViewHome:request(event.url.."?val=done")
        end
     end
    end
  
    if event.type == "loaded" then         
     if welcomeLoaded == false then     
        clearInitialStuff();     
     end
    end
  
    if event.errorCode then
     if tostring(event.errorCode) ~= "-999"  then     
        native.showAlert( "Error!", "Internet Connection Appears To Be Offline.", { "OK" }, onComplete )
     end
    end
    return true;
end


[TOPIC: post.html]
#4

fazilreyaz

[GLOBAL: userInfoPane.html]
fazilreyaz
  • Enthusiast

  • 67 posts
  • Corona SDK

Anyone there who can help?



[TOPIC: post.html]
#5

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,013 posts
  • Corona SDK

Why can't you send them at load and why isn't it reliable? Do you get an error? I have never seen it fail unless there is some connectivity issue.



[TOPIC: post.html]
#6

fazilreyaz

[GLOBAL: userInfoPane.html]
fazilreyaz
  • Enthusiast

  • 67 posts
  • Corona SDK

Why can't you send them at load and why isn't it reliable? Do you get an error? I have never seen it fail unless there is some connectivity issue.

 

At the beginning user have to sign in first. And after that they are being redirected to coupons page.

Here I need to check the location where the coupon was clicked. Sometimes user will claim that the coupon was clicked here, I should be able to see that whether they are right or wrong.



[TOPIC: post.html]
#7

fazilreyaz

[GLOBAL: userInfoPane.html]
fazilreyaz
  • Enthusiast

  • 67 posts
  • Corona SDK

  Best Answer

Okay I did it. I captured the event.url and stopped the request and requested new url with location parameters and performed the same operation on that url.

 

Thanks,




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: webview, location, web, event, parameters