open link in webview on iPhone (prob. iPad as well)

Hello everybody,

I am getting crazy about this problem.

I use a webview in my app to show a map that holds positions where people already played my game. When clicking on this points a box appears where the people can click on a ‘play’ button which should open a new url where I search for a certain string to cause the app to load this map.

This works fine on android, desktop and even in safari on a mac, but it does NOT work on an iPhone.

It seems not to be related to corona as the problem happens in the iPhone simulator by using only safari as well.

I tried like everything but I can not figure out what is the problem. (Tried to open the link via javascript (window.open()), certain css attributes, and every other idea I found in the internet)

I think it is related to the way this link is created (via javascript) as the exact same link work when implemented via html.

Maybe somebody already came across this problem and could share some insight?

Here is a demo page:

http://bucketman-game.com/mapApp2.html

When opening it with an iPhone and tapping on a marker there will appear a box with a link  -play-. Tapping on it will close the window but nothing more.

What actually should happen can be seen when tapping on the  -play- link in the top left corner.

Would be super happy about any kind of feedback on this one.

Thank you in advance,

Felix

While this is pretty much a Lua crowd, maybe if you posted the Javascript you’re using, someone might have some ideas.

Rob

Hei Rob, you are right!

This is the line that creates the marker:

marker = addMarker(layer\_markers,parseFloat(mapList[i]['lon']),parseFloat(mapList[i]['lat']),"\<span style='font-size:"+markerFontSize+"em'\>\<b\>"+mapList[i]['name']+"\</b\>\<br\> uploaded by: "+mapList[i]['uploader']+"\<br\> highscore: "+mapList[i]['highScore']+"\<br\> highscore by: "+mapList[i]['highScoreBy']+"\<br\> visits: "+mapList[i]['visits']+"\<br\> \<a href='http://www.bucketman-game.com/loading.php?map="+mapList[i]['name']+"'\> -PLAY- \</a\> \</span\>",showPopUp,color);

In line two the link is created.

I am using OpenLayers

(http://bucketman-game.com/map/openlayers/OpenLayers_bm2.js and http://bucketman-game.com/map/util.js and http://www.openstreetmap.org/openlayers/OpenStreetMap.js))

I am quite noob in js, I just modified the code until it (mostly) did what I wanted it to do.

I hope this is enough and the correct code to be analized.

Best,

Felix

I don’t know if this is the issue or not, but normally, HTML wants double quotes for attributes like the href parameter. HTML 4.01 strict may be picker about it, but HTML5 is fairly sloppy with enforcing rules, but the standard is JS is to use single quotes for JS parameters and doubles for HTML. 

I don’t see anything obvious. Maybe someone from the community has some other suggestions.  You might also want to consider the Apple Developer Forums. They don’t need to know you’re using Corona since the issue seems to be Safari/UIWebView on iOS processing your HTML/JS.

Rob

Hello Rob,

thank you very much for your help.

I changed the quotes but this did not change anything :frowning:

the link in the top left corner is as well single quoted, and works.

The funny thing is, that I can open these links in a new tab and it works like expected…

Why Apple always needs to complicate my life as developer?

I will ask this in the Apple Developer Forums, as well as if somebody know this problem and how to solve it…

Thank you again Rob,

Felix

Just in case somebody runs into the same or similar problems, its nothing related to corona.

I am not sure what caused the problem, but I resolved it by using openlayers v3 instead of v2 and using a vector layer instead of a marker layer.

Best regards and thanks once again to Rob!

Felix

While this is pretty much a Lua crowd, maybe if you posted the Javascript you’re using, someone might have some ideas.

Rob

Hei Rob, you are right!

This is the line that creates the marker:

marker = addMarker(layer\_markers,parseFloat(mapList[i]['lon']),parseFloat(mapList[i]['lat']),"\<span style='font-size:"+markerFontSize+"em'\>\<b\>"+mapList[i]['name']+"\</b\>\<br\> uploaded by: "+mapList[i]['uploader']+"\<br\> highscore: "+mapList[i]['highScore']+"\<br\> highscore by: "+mapList[i]['highScoreBy']+"\<br\> visits: "+mapList[i]['visits']+"\<br\> \<a href='http://www.bucketman-game.com/loading.php?map="+mapList[i]['name']+"'\> -PLAY- \</a\> \</span\>",showPopUp,color);

In line two the link is created.

I am using OpenLayers

(http://bucketman-game.com/map/openlayers/OpenLayers_bm2.js and http://bucketman-game.com/map/util.js and http://www.openstreetmap.org/openlayers/OpenStreetMap.js))

I am quite noob in js, I just modified the code until it (mostly) did what I wanted it to do.

I hope this is enough and the correct code to be analized.

Best,

Felix

I don’t know if this is the issue or not, but normally, HTML wants double quotes for attributes like the href parameter. HTML 4.01 strict may be picker about it, but HTML5 is fairly sloppy with enforcing rules, but the standard is JS is to use single quotes for JS parameters and doubles for HTML. 

I don’t see anything obvious. Maybe someone from the community has some other suggestions.  You might also want to consider the Apple Developer Forums. They don’t need to know you’re using Corona since the issue seems to be Safari/UIWebView on iOS processing your HTML/JS.

Rob

Hello Rob,

thank you very much for your help.

I changed the quotes but this did not change anything :frowning:

the link in the top left corner is as well single quoted, and works.

The funny thing is, that I can open these links in a new tab and it works like expected…

Why Apple always needs to complicate my life as developer?

I will ask this in the Apple Developer Forums, as well as if somebody know this problem and how to solve it…

Thank you again Rob,

Felix

Just in case somebody runs into the same or similar problems, its nothing related to corona.

I am not sure what caused the problem, but I resolved it by using openlayers v3 instead of v2 and using a vector layer instead of a marker layer.

Best regards and thanks once again to Rob!

Felix