TTMSFNCWebBrowser + WhastApp + macOS

Hi,

I need to create a form window in my application where the user can access WhatsApp web.

I used TTMSFNCWebBrowser which on Windows works perfectly, however, on macOS when accessing the page “https://web.whatsapp.com/” WhatsApp displays the message that it only works on Safari 10 or higher (on my Mac the version is installed 14.0.1).

Does anyone have any suggestions to resolve this?

I already tried to install Chrome and leave it as the default browser but it didn't work.

Hi,

Can you try with the following code:

uses
  Macapi.WebKit;

procedure TForm1.FormCreate(Sender: TObject);
var
  w: WKWebView;
begin
  w := TWKWebView.Wrap(TMSFNCWebBrowser1.NativeBrowser);
  if Assigned(w) then
    w.setCustomUserAgent(NSStrEx('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/601.6.17 (KHTML, like Gecko) Version/9.1.1 Safari/601.6.17'));
end;

Please note that there might be additional issue rising when using web.whatsapp.com on an embedded browser.

I tried to use this code but my WkWebView does not have the setCustomuserAgent().

  1. Remove MacApi.WebKit
  2. Add MacApi.AppKit & MacApi.ObjectiveC
  3. Add the following declaration to your form
  WKWebViewClass = interface(NSViewClass)
    ['{975E5DD2-26EF-4824-9199-6768A1C93D05}']
  end;

  WKWebView = interface(NSView)
    ['{A591EAE9-4467-403D-8987-94B94780B1C4}']
    procedure setCustomUserAgent(customUserAgent: NSString); cdecl;
    function customUserAgent: NSString; cdecl;
  end;

  TWKWebView = class(TOCGenericImport<WKWebViewClass, WKWebView>)
  end;

It compiled but the same problem occurred:

Can you try with this agent instead:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8

It worked. :-)

Thank you.

1 Like

Thanks for confirming