irigsoft Posted September 14 Share Posted September 14 Hello, I try to get UniApplication.UniPlatform on UniGUIServerModuleHTTPCommand, when user start Session, but I get "Access violation at address". Is it possible to get this information from something else like ExtractSessionId(ARequestInfo.UnParsedParams)? I have write some restrictions if Platform is Android or IPhone and I need to know this when Session Start. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted September 17 Author Share Posted September 17 ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 17 Share Posted September 17 Hello @irigsoft Can you try also this approach? procedure TUniServerModule.UniGUIServerModuleHTTPCommand( ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean); function getOSName(AUserAgent: string): string; begin if AUserAgent = '' then begin Result := 'Unknown OS'; Exit; end; AUserAgent := LowerCase(AUserAgent); if Pos('win', AUserAgent) > 0 then Result := 'Windows' else if Pos('mac', AUserAgent) > 0 then Result := 'Macintoch' else if Pos('linux', AUserAgent) > 0 then Result := 'Linux' else if Pos('android', AUserAgent) > 0 then Result := 'Android' else if Pos('like Mac', AUserAgent) > 0 then Result := 'iOS' else Result := 'Unknown OS'; end; begin // getOSName(ARequestInfo.UserAgent) end; Based: 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 17 Share Posted September 17 * like mac Quote Link to comment Share on other sites More sharing options...
irigsoft Posted September 17 Author Share Posted September 17 1 hour ago, Sherzod said: Hello @irigsoft Can you try also this approach? procedure TUniServerModule.UniGUIServerModuleHTTPCommand( ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean); function getOSName(AUserAgent: string): string; begin if AUserAgent = '' then begin Result := 'Unknown OS'; Exit; end; AUserAgent := LowerCase(AUserAgent); if Pos('win', AUserAgent) > 0 then Result := 'Windows' else if Pos('mac', AUserAgent) > 0 then Result := 'Macintoch' else if Pos('linux', AUserAgent) > 0 then Result := 'Linux' else if Pos('android', AUserAgent) > 0 then Result := 'Android' else if Pos('like Mac', AUserAgent) > 0 then Result := 'iOS' else Result := 'Unknown OS'; end; begin // getOSName(ARequestInfo.UserAgent) end; Based: thanks, my problem is (how to check if navigator.connection is supported from browser of user ?): I want to use this code on all devices Android and Iphone (but Safari not support navigator) function window.afterrender ( ....... // if (window?.navigator?.connection) { //- this work on IPhone + Safary, but not work on Android 5 + Google Chrome // this work only on Android var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; //alert (navigator.connection); var type = connection.effectiveType; function updateConnectionStatus() { //console.log("Connection type changed from " + type + " to " + connection.effectiveType); type = connection.type || connection.effectiveType; ajaxRequest(sender, "connectionType", ["ctype="+type]); }; updateConnectionStatus(); connection.addEventListener('change', updateConnectionStatus); // } // else { // var type = "None"; // ajaxRequest(sender, "connectionType", ["ctype="+type]); // } Quote Link to comment Share on other sites More sharing options...
irigsoft Posted September 17 Author Share Posted September 17 2 hours ago, irigsoft said: thanks, my problem is (how to check if navigator.connection is supported from browser of user ?): I want to use this code on all devices Android and Iphone (but Safari not support navigator) function window.afterrender ( ....... // if (window?.navigator?.connection) { //- this work on IPhone + Safary, but not work on Android 5 + Google Chrome // this work only on Android var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; //alert (navigator.connection); var type = connection.effectiveType; function updateConnectionStatus() { //console.log("Connection type changed from " + type + " to " + connection.effectiveType); type = connection.type || connection.effectiveType; ajaxRequest(sender, "connectionType", ["ctype="+type]); }; updateConnectionStatus(); connection.addEventListener('change', updateConnectionStatus); // } // else { // var type = "None"; // ajaxRequest(sender, "connectionType", ["ctype="+type]); // } Thanks again, I correct my code to and now it's work : from: // if (window?.navigator?.connection) { //- this work on IPhone + Safary, but not work on Android 5 + Google Chrome to : if (window.navigator && window.navigator.connection) { //- this work on IPhone + Safary + Android + Google Chrome ... my code from above }; I will use information from userAgent for some of my functions. 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.