Urgent please! Link to external page inside WebGL doesnt work on Safari

Hi I use this code in Unity:

using UnityEngine;

public class UrlOpenner : MonoBehaviour

{
public string Url;

public void Open()
{
    Application.OpenURL(Url);
}

}

and works great on google/android but doesnt work on safari/iphone

Please is urgent!!

Hey @lreyesreginato

Welcome to the forum.

This question seems more Unity specific than related to our Universal AR SDK, thus we encourage you to post such questions on Unity answers or forum, where you may have faster response to such queries.

That said, Application.OpenURL is subjected to the permissions and limitations of your app’s current platform and environment. Especially for mobile browsers it cannot be used to open local files or will always try to open the webpage in new tab. Here’s a quick webgl plugin that allows you to open URL/resource in the browser (PFA). You should be able to just call Nfynt.NPlugin.OpenURL(url) which will open it in a new tab.

HTH

Best,

NPlugin.zip (1.3 KB)

2 Likes

The question you asked is very good. I read it carefully but could not find anyone to help me understand it. Anyone can describe it correctly here https://forum.zap.works/t/urgent-please-link-to-external-page-inside-webgl-doesnt-nuwaveairfryer-work-on-safari/8981/2

Hello @muellerswag1234

Safari is relatively more strict when compared to Chrome or Firefox, in terms of handling browser permissions. And then there’s limitations of Application.OpenURL API for WebGL which you can read here.

In this case, you may wanna check your Safari settings to make sure Block Pop-ups is disabled for OpenURL API to work. Otherwise you may try opening URL in same tab as following:

#if UNITY_WEBGL && !UNITY_EDITOR
        Nfynt.NPlugin.OpenURLInSameTab(URL);
#else
        Nfynt.NPlugin.OpenURL(URL);
#endif

Couple of other things to check would be:

  • You are calling this method on user input event i.e. touch, click, etc.
  • You are not calling this from async part of your code

Best,

1 Like

Thanks!,

I had the same issue and after applying your code suggestion, I was able to fix the open url problem in Safari.

2 Likes