iOS Question IOS Webview useragent

schalkgreyling

Member
Licensed User
Longtime User
Hi all,

I need to change the useragent of the Webview browser, does anyone know how to go about doing this ?

I found the thread to do this for Android, but I can manage to convert for IOS:

Dim Obj1 AsReflector
Obj1.Target = WebvMsgbox(Obj1.ToString, "Target")
Obj1.Target = Obj1.RunMethod("getSettings")
Obj1.RunMethod2("setUserAgentString", "Desktop", "java.lang.String")

Thanks in advance.
 

JanPRO

Well-Known Member
Licensed User
Longtime User
Before using WebView call this sub:
B4X:
Sub SetUserAgent(UserAgent As String)
    Dim NaObj As NativeObject = Me
    NaObj.RunMethod("SetUserAgent:",Array(UserAgent))  
    #If Objc
        -(void)SetUserAgent:(NSString*)UserAgent{
            NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:UserAgent, @"UserAgent", nil];
            [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
        }
    #End if
End Sub
 
Upvote 0
Top