Jump to content


Photo

iPhone GeoLocation Test Code - Please Help


  • Please log in to reply
3 replies to this topic

#1 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 354 posts
  • LocationMelbourne Australia

Posted 17 December 2017 - 07:49 AM

Please advise how to make this js code work - thanks in advance.

 

 

procedure TMainmForm.UnimButton1Click(Sender: TObject);
begin
  UniSession.AddJS(
 
    'navigator.geolocation.getCurrentPosition(success, fail) '+
 
    'success(position)'+
    '{ '+
    '  alert("Your latitude: " + position.coords.latitude + "longitude: " + position.coords.longitude); '+
    '} '+
 
    'fail(error)'+
    '{ '+
    '  switch(error.code) '+
    '    { '+
    '      case 0: '+ // UnKown
    '        alert(error.message); '+
    '        break; '+
    '      case 1: '+ // Denied
    '        alert(error.message); '+
    '        break; '+
    '      case 2: '+ // UnAvailable
    '        alert(error.message); '+
    '        break; '+
    '      case 3: '+ // TimeOut
    '        alert(error.message); '+
    '        break; '+
    '    } '+
    '} '
 
  );
 
end;

  • 1

Andy


#2 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 354 posts
  • LocationMelbourne Australia

Posted 18 December 2017 - 05:03 AM

Moving forward, I get the following error from an iPhone X even though: Location Services -> Safari Websites is set to "While Using the App"

 

"Origin does not have permission to use Geolocation service"

 

Can someone please advise how to resolve - thanks.


  • 0

Andy


#3 Oliver Morsch

Oliver Morsch

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 269 posts
  • LocationGermany

Posted 18 December 2017 - 11:36 AM

You have to use SSL (HTTPS).


  • 0

#4 andyhill

andyhill

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 354 posts
  • LocationMelbourne Australia

Posted 20 December 2017 - 05:16 AM

Thanks for the pointer


  • 0

Andy





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users