Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the Cordova iOS plugins with Ionic? #91

Open
tatham opened this issue Apr 18, 2023 · 14 comments
Open

Using the Cordova iOS plugins with Ionic? #91

tatham opened this issue Apr 18, 2023 · 14 comments

Comments

@tatham
Copy link

tatham commented Apr 18, 2023

Just curious as to whether anyone has done any work to get the Cordova iOS plugins working in an Ionic app?

@timliu55
Copy link
Collaborator

timliu55 commented Apr 19, 2023

@tatham - Nothing about Ionic has done from Citrix.
If you encounter any problems, we are happy to support.

@tatham
Copy link
Author

tatham commented Apr 19, 2023

Thanks, I’m looking at creating a wrapper for each plugin. I only need the microVPN functionality at this stage, so can I add just the core and network plugins? The Readme describes adding them all…

@timliu55
Copy link
Collaborator

@tatham - we don't suggest that, but in theory you can remove some of them
Besides CTXMAMNetwork+CTXMAMCore, you also need CTXMAMAppCore to fetch policies from CEM server, otherwise the network access policy can only be unrestricted

@tatham
Copy link
Author

tatham commented May 2, 2023

Thanks @timliu55, I'll include them all.
I'm having a few issues, wondering whether anyone can suggest what the underlying problem might be, or how to better troubleshoot?

Our Ionic app deploys via Secure Hub. When opening the app, it switches to Secure Hub, as expected, and in the logs I see messages about the microVPN being successfully initialised (along with other MAM SDK components) and successful Secure Hub authentication.

  1. It then switches back to our Ionic app, which displays the app login page (as expected) briefly before displaying a completely white screen. I'm pretty sure this is a bug or exception being thrown, but I don't see anything relevant in the logs (and it doesn't happen when running in the Simulator.)
  2. If I minimise the app, and then resume it, the white screen is replaced by our log in screen. If I attempt to log in, I get a 'server with specified hostname could not be found'. To test that the server URL is correct, I also have a link on the login page which opens the server URL successfully using inAppBrowser. (This behaviour is the same for any of our servers on the internal network, which are only accessible if the microVPN is running.)

Attaching to the app running on the iPad from XCode has only worked once, most of the time it gives me an error about being denied :-(

Any suggestions about what might be happening, or approaches to troubleshooting?

@tatham
Copy link
Author

tatham commented May 3, 2023

Bit of an update:

  • I switched back to using a Development profile instead of the Enterprise profile, and I'm getting more info in the logs.
  • I removed the Citrix compliance plugin, because that was preventing me from attaching a debugger (Xcode).
  • As a test, I commented out the call to initializeSDKs (and I don't have any other calls to the plugins), made no other changes, and deployed that. There was no white screen, so the white screen issue must be related to the plugin, or how I'm calling it

@timliu55
Copy link
Collaborator

timliu55 commented May 4, 2023

@tatham Typically speaking, the error 'server with specified hostname could not be found' indicates the network plugin does not succeed to be initialized - you need to collect managed app logs from secure hub and then find below message in app logs "Network SDK is initialized."

@tatham
Copy link
Author

tatham commented May 4, 2023

Thanks @timliu55 Did you notice that in the situation I described, even though the login attempt fails with the 'server ... could not be found', if I then click on a link on the same login page, without doing anything else, the server URL opens without any problem? In other words, there is a subtle difference between inAppBrowser opening the URL and submitting a request to the same server as part of the login form submission.
Yes, as I described: I see messages about the microVPN being successfully initialised (along with other MAM SDK components).

@tatham
Copy link
Author

tatham commented May 4, 2023

Another observation: when calling the initializeSDKs function, neither of the callbacks ever fires, not even if I add logging in the CtxMAMCoreBridge.js file that is part of the core plugin...

@tatham
Copy link
Author

tatham commented Aug 15, 2023

I started working on this again, as we never got it working. I'm using the recently released 23.8.0 version. I had to make a change in the CtxMAMCoreBridge.m file to get the callbacks working. (Now I'm getting the expected success or failure responses when calling initializeSDKs).

Our app uses the IBM MobileFirst plugin for authentication. The problem I'm having is that although the microVPN has successfully initialised, the login page reports 'specified hostname could not be found'.

There are two ways that I can get around this (obviously neither are acceptable):

  • If I swipe the app away, and then open it again, log in works perfectly.
  • If I add an alert popup just before triggering the login prompt, it works first time.

I'm guessing that it's all about the timing of the various calls and events in the app, but I've tried everything I can think of (including sleeping for a few seconds) and it won't work the way it should.

Any suggestions about what the issue might be, or troubleshooting steps?

@timliu55
Copy link
Collaborator

@tatham - I am not sure what happened if I cannot see the SDK logs, my suggestions are

  1. Find the Cordova sample app in the released zip, try to make it work and then check the logs diff and code diff between our sample app and your app
  2. Escalate this request to raise a support case, and supply all the detailed information you can collect

@ninaDeimos
Copy link

ninaDeimos commented Jul 24, 2024

@tatham

I started working on this again, as we never got it working. I'm using the recently released 23.8.0 version. I had to make a change in the CtxMAMCoreBridge.m file to get the callbacks working. (Now I'm getting the expected success or failure responses when calling initializeSDKs).

Could you share what you changed in CtxMAMCoreBridge.m? Because I'm also not getting any callback.

@tatham
Copy link
Author

tatham commented Jul 26, 2024

@ninaDeimos

Could you share what you changed in CtxMAMCoreBridge.m? Because I'm also not getting any callback.

I'm not an Objective C programmer, and the change I made doesn't seem to be necessary, but this modified code worked for me at the time:

- (void) initializeSDKs:(CDVInvokedUrlCommand*)command {
    CTXMAMLOG_Info(CTXLog_SourceName, @"Core SDK delegate set.");
    [CTXMAMCore setDelegate:(id<CTXMAMCoreSdkDelegate>) [MAMCoreSDK sharedInstance]]; //TODO: nonnull check or log

    CTXMAMLOG_Info(CTXLog_SourceName, @"Invoking initialized sdks from plugin.");
    [CTXMAMCore initializeSDKsWithCompletionBlock: ^(NSError * nilOrError) {
        CTXMAMLOG_Info(CTXLog_SourceName, @"initializeSDKsWithCompletionBlock nilOrError : %@",[nilOrError localizedDescription]);
        if (!nilOrError) {
        [CTXMAMCore setCordovaInfoAfterBeingInitialized];
           [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
        }
        else {
           NSDictionary* errorInfoDict = @{ kCoreErrorCode : @(nilOrError.code), kCoreUserInfoMsg : nilOrError.localizedDescription};
            [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:errorInfoDict] callbackId:command.callbackId];
        }
    }];
}

I basically just moved the return statement into the if...else block.

@ninaDeimos
Copy link

@tatham Thank you. I don't understand why, but in my case it also helped. I'm getting the success callback now.
But I'm still not getting the registerSdksInitializedAndReady event. Did that work for you or did you not use it?

@tatham
Copy link
Author

tatham commented Jul 30, 2024

@ninaDeimos No, registerSdksInitializedAndReady has never worked for me either, I managed to get by without it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants