Reply To: Moved: Error

Welcome! Forums Unity Plugins In-App Web Browser Moved: Error Reply To: Moved: Error

#1446
JezPez
Participant

I figured it out.

Seems like the WebView may always throw a Domain=WebKitErrorDomain Code=102 “Frame load interrupted” when it encounters a redirect.

Anyway you are still able to register for the openUrl in an AppDelegate .mm class of your choosing.

To help some future Googlers who come here, this is how I was able to do it:

1. Register a Url in Unity for iOS: PlayerSettings > Other Settings > Supported URL Schemes > Here, add your apps url identifier. EG: com.Company.ProjectName
2. Make a new Unity Game Object Prefab at the root of your scene, call it OpenUrlReceiver.
3. Attach a script to the OpenUrlReceiver, call it OpenUrlReceiver.cs. Put one method inside:
public void ReceiveOpenUrl(string url)
{
Debug.Log(“Got an app open url: ” + query);
}
4.Make sure the Assets>Plugins>iOS contains the following files from this plugin:
InAppBrowserViewController.mm
InAppBrowserViewController.h
iOSInAppBrowser.mm
OrientationNavigationViewController.h
OrientationNavigationViewController.m
5. Create your own .mm file in the same place as those above called MyApp.mm and inside put the following obj c code:

#import <UIKit/UIKit.h>
#import “UnityAppController.h”
#import “UI/UnityView.h”
#import “UI/UnityViewControllerBase.h”

@interface MyApp : UnityAppController
– (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation;

@end

@implementation MyApp

extern void UnitySendMessage(const char*, const char*, const char*);

– (BOOL)application:(UIApplication*)app openURL:(NSURL*)url options:(NSDictionary<NSString*, id>*)options
{
const char* fullUrl = [[[url absoluteString] stringByRemovingPercentEncoding] UTF8String];

UnitySendMessage(“OpenUrlReceiver”, “ReceiveOpenUrl”, fullUrl);

return [super application:app openURL:url options:options];
}

6. Build your app to iOS and open in Xcode
7. Run the app on a device.
8. Open a browser to somewhere which will end up with a redirect flow back to your app, or go to this test url:https://universaldeeplinking.imaginationoverflow.com/test
and enter a url your app expects: com.Company.ProjectName://hellothere
9. See in the Xcode logs, the debug output:
Got an app open url: com.Company.ProjectName://hellothere