Fábio Matte Posted July 12, 2018 Share Posted July 12, 2018 How do I detect the browser that is running the application? Because this code only works right when I run in debugger: var C: TUniClientInfoRec; begin label_ra.Caption: = UniApplication.RemoteAddress; C: = UniApplication.ClientInfoRec; label_bt.Caption: = C.BrowserType; label_bv.Caption: = IntToStr (C.BrowserVersion); label_os.Caption: = C.OSType; But when I run inside Apache or IIS, it is not returning me anything, it comes in white. Quote Link to comment Share on other sites More sharing options...
ToeKneeH72 Posted September 24, 2020 Share Posted September 24, 2020 Have you managed to resolve this issue? I have a similar issue i need to return the remote address from Apache and RemoteAddress returns an empty string. Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted September 24, 2020 Author Share Posted September 24, 2020 4 hours ago, ToeKneeH72 said: Have you managed to resolve this issue? I have a similar issue i need to return the remote address from Apache and RemoteAddress returns an empty string. As I was unable to get help and find something related to the problem, I ended up giving up using the function I would like. But if at any time someone posts I help us, then I review again. Quote Link to comment Share on other sites More sharing options...
alfr Posted September 24, 2020 Share Posted September 24, 2020 For getting the remote ip, use instead - UniSession.RemoteIP I've also had some problems using the ClientInfoRec. I came to the conclusion that it can be used first after the first form is shown. So in the form's AfterShow Event. An alternative is to take it directly from UniSession.UserAgent text. But depending on what you are after there is also some interesting info in UniApplication.UniPlatform For example to get the user's device function GetUserDevice: String; begin if (upiPad in UniApplication.UniPlatform) then Result:='iPad' else if (upiPod in UniApplication.UniPlatform) then Result:='iPod' else if (upiPhone in UniApplication.UniPlatform) then Result:='iPhone' else if (upAndroid in UniApplication.UniPlatform) then Result:='Android Device' else if (upDesktop in UniApplication.UniPlatform) then Result:='PC' else Result:='unknown!'; end; or some other kinds.. var uPlat: TUniPlatforms; uPlat := UniApplication.UniPlatform; function TMainForm.DetectDeviceType: string; begin if (upPhone in uPlat) then Result := 'Phone' else if (upTablet in uPlat) then result := 'Tablet' else if (upDesktop in uPlat) then result := 'PC'; end; function TMainForm.DetectModel: string; begin if (upiPad in uPlat) then Result := 'iPad' else if (upiPod in uPlat) then Result := 'iPod' else if (upiPhone in uPlat) then Result := 'iPhone' else if (upAndroid in uPlat) then Result := 'Android Device' else if (upDesktop in uPlat) then Result := 'PC'; end; function TMainForm.DetectOperationSystem: string; begin if (upAndroid in uPlat) then Result := 'Android' else if (upiOS in uPlat) then Result := 'iOS' else if (upDesktop in uPlat) then Result := 'Desktop OS'; end; function TMainForm.DetectPlatform: string; begin if (upDesktop in uPlat) then result := 'Desktop' else if (upMobile in uPlat) then result := 'Mobile'; end; 1 Quote Link to comment Share on other sites More sharing options...
ToeKneeH72 Posted September 29, 2020 Share Posted September 29, 2020 I tried UniSession.RemoteIP in the AfterShow Event, this works fine for the standalone server but still no joy when compiled for use Apache2.4 So I have given up and resorted to a following PHP hack:- I have PHP script server side “loader.php”, something along the lines off <?php $ipaddr = $_SERVER['REMOTE_ADDR']; header("Location: http://MyServer/MyUniGuiApp/?ip=".$ipaddr); exit ?> you could return the browser version if needed, using $_SERVER['HTTP_USER_AGENT'] Then in my MyUniGuiApp I assign the IP to a variable IPAddress:=UniApplication.Parameters.Values['ip']; To load my application I use http://MyServer/loader.php Yes, PHP wont always be available , Yes I know this is an awful hack, but it will have to do until I improve my skills and find a more elegant solution. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.