JezPez

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: Moved: Error #1451
    JezPez
    Participant

    Upon further investigation, most identity providers are deliberately blocking use of In-App browsers for Authentication because the default in app browser for iOS and Android is not secure.

    Read more here: https://auth0.com/blog/google-blocks-oauth-requests-from-embedded-browsers/

    As such, this plugin is not appropriate for OAuth interactive login purposes.

    The proper iOS way for authentication is to open a ASWebAuthenticationSession (iOS 12+) or SFAuthenticationSession (iOS 11):
    https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession
    https://developer.apple.com/documentation/safariservices/sfauthenticationsession

    Sadly there is no plugin out there which opens a secure browser so I guess I’m writing one!

    Cheers,

    in reply to: Moved: Error #1447
    JezPez
    Participant

    I forgot one step:

    Before you build the iOS project from Unity. (before step 6 above).
    You need to move the InAppBrowserBridge prefab into your scene at the root. (Assets/InAppBrowser/Prefabs/InAppBrowserBridge)

    in 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

    in reply to: Moved: Error #1445
    JezPez
    Participant

    You were correct, I had removed the InAppBrowserViewController.mm Thanks!

    I am having another issue now. My browser session ends in a 302 redirect to the apps custom Url Type, when I would like to close the browser and come back to the application. I know this Url works to open the app because, from a link, I am able to launch the app.

    But when this In App Browser receives the 302 redirect, I see the following error in the logs in Xcode:

    ERROR:Error Domain=WebKitErrorDomain Code=102 “Frame load interrupted” UserInfo={NSErrorFailingURLStringKey=com.jigspace.jigsignupsample://dev-jigspace.auth0.com/ios/com.JigSpace.JigSignupSample/callback?code=QlT1tYAYMyb5aR2&state=itsastate
    InAppBrowserBridge:OnBrowserFinishedLoadingWithError(String)

    What should I do to close the browser upon receiving a redirect like this?

    BTW: I am trying to achieve an OAuth2 interactive flow.

    in reply to: Deep Link Support #1443
    JezPez
    Participant

    EDIT : sorry I see you moved my thread here https://www.kokosoft.pl/forums/topic/moved-error/

    • This reply was modified 5 years ago by JezPez.
Viewing 5 posts - 1 through 5 (of 5 total)