citrix / citrix-mam-sdks

The MAM SDK instrument your apps to enable enforcing policies and controls that are configured in Citrix Endpoint Management.
https://developer.cloud.com/citrixworkspace/mobile-application-integration
11 stars 4 forks source link

MAM SDK Cordova iOS plugin #61

Open mylvs opened 2 years ago

mylvs commented 2 years ago

Good day! Inline with our integration with MAMSDK, we are also using Cordova iOS. I was able to see documentation from your website but we weren't able to find link to download the Cordova iOS plugin. My devs have raised it in Citrix support (ticket#81093090) and Citrix support person have indicated the following: "I could not find anything related to Cordova either. So I checked further and found the following official Citrix article which does not have Cordova listed for ios. https://docs.citrix.com/en-us/mdx-toolkit/mam-sdk-overview.html If any particular feature not listed in the article then it is considered not supported. I have checked on this and found that our development team is still working on this in order to support Cordova for iOS apps"

I would like to check with you about the timeline of release for the Cordova iOS plugin?

At the moment, we are less than 3 months to EOL for MDM. We need a bit of time to implement and test this for all of our applications. This is really a big risk in our business and appreciate the support and help we can get.

regards, Myla

jaspreetsingh-citrix commented 2 years ago

Hi @mylvs, I would suggest to please get in touch with our PM Chetan Thakker for this request.

mylvs commented 2 years ago

Thanks for your response @jaspreet1. Can you provide me with Chetan's email address please? Thanks!

chetanthakker commented 2 years ago

Hello @mylvs - there has been a change in our current MAM SDK strategy - given the number of frameworks ( ObjC, Swift, Cordova, Ionic, Xamarin, Maui.net, and so on...) it is a challenge for our teams to support and maintain all of them. Hence we have decided to only support the ones that have been GA'd. For iOS: they are Swift and ObjC. This is the reason why there is no documentation or downloads for Cordova. If your app is not built in a supported framework - The workaround is to leverage the Citrix SSO app for Secure Access. Regarding MDX - the current support is until July due to the dependency on iOS and Android scheduled updates - our teams will be evaluating those to see what we can support

tatham commented 1 year ago

Hi @chetanthakker - if there is no supported Cordova plugin for iOS, I assume that we need to follow the steps for embedding the SDK in a native app (adding frameworks, Keychain sharing, URL type) and injecting the ipa file into an MDX wrapper? (I have done that and successfully deployed our Cordova apps to Xenmobile, but when opening the app it doesn't launch the microVPN, even though the CTXMAMNetwork was included and there are no error reported in the Console app.)

Anyone have any thoughts, or experience with treating a Cordova iOS app as a native app instead of using the unsupported plugin?

timliu55 commented 1 year ago

Hello @tatham - many thanks for your attention to Citrix products! We just started to support different frameworks. Xamarin has been released days ago - https://github.com/citrix/citrix-mam-sdks/releases/tag/23.1.1 And Cordova is on its way and should be released in the early Feb.

tatham commented 1 year ago

Thanks @timliu55 - I'm very keen to do some initial testing before you release it, and provide feedback, if that helps.

timliu55 commented 1 year ago

Thanks @tatham - I didn't see a precedent to do that, let's just wait for a couple of days

timliu55 commented 1 year ago

Hello @tatham - not sure whether you are notified by GitHub, we've pre-released MAM SDK Cordova iOS on Feb. 8 Your feedback will be very welcome and helpful to us https://github.com/citrix/citrix-mam-sdks/releases/tag/23.1.2

tatham commented 1 year ago

Hi @timliu55 - apologies for the delay is responding. I have been trying out the new version of the plugin (and the sample app) but haven't managed to find time to complete that yet. As a matter of interest, what would you like me to do with any feedback/suggestions?

timliu55 commented 1 year ago

Hi @tatham - nice to hear your response, please just take your time And if possible, we expect below feedback

  1. Are the docs clear enough to help you build and run sample app?
  2. Are the docs clear enough to help you integrate the SDKs with your corporate apps?
  3. Are SDKs bug free?
  4. What else you expect our SDKs to contain in future?
tatham commented 1 year ago

(Thanks @timliu55, I meant how would you like me to report my feedback, here or somewhere else?)

I'm doing some initial testing with the Citrix CordovaiOSSampleApp before trying to get the MAMSDK working with our own app.

My main requirement for the SDK is to get a MicroVPN tunnel running, so that we can connect to a server on our internal network. This is what I've done:

Then I built and deployed the CordovaiOSSampleApp to XenMobile/SecureHub.:

To me it looks like the microVPN isn't loading (which is basically the same behaviour I described earlier in this thread when I was following the steps to add the MAM SDK to a native iOS app).

Any suggestions for debugging the issue?

Thanks

timliu55 commented 1 year ago

@tatham, it is fine to report your issue right here, and it is better to open a new issue I need to confirm several things:

  1. Have you ever succeeded to connect to the target server by Citrix Secure Web? (If not, please do it to make sure the target server is configured correctly)
  2. Did you deploy CordovaiOSSampleApp.mdx file on the CEM server? (If so, the sample app will flip to secure hub and then flip back to finish the initialization)
  3. If you've done above, please collect logs by secure hub and attach here, we'll help you to find what is wrong
tatham commented 1 year ago

Thanks, answers to your questions:

  1. Yes, pasting the same URL into Secure Web works, and the page loads.
  2. Yes, CordovaiOSSampleApp.mdx file deployed as an MDX app (Tunneled - Web SSO), but when I open the app it doesn't flip to Secure Hub. (When I first installed it there was a message with something like 'don't have access to this app', but that hasn't appeared again even if I delete the app.)

I'm not keen to upload any device logs here, I can create a support ticket if necessary. Ideally I need to understand how it is supposed to work/behave, so that I can start implementing the SDK into our own apps, so:

Thanks.

timliu55 commented 1 year ago

@tatham - if the app does not flip to secure hub, that indicates the build process is not fully correct We have a document in the zip - under Cordova_iOS_Plugins\Documentation\Readme.pdf Did you follow all the steps on the PDF without errors?

Answers to your questions:

ShawnInTibco commented 1 year ago

Hi @tatham, please try to delete the link "CTXMAMAppCore" in "Link Binary With Libraries" of your own target. And link it back again. Rerun the app and try it again.

This step may solve the "flip problem"--an app doesn't flip to SecureHub at first open. CC: @timliu55

tatham commented 1 year ago

Thanks @ShawnInTibco, I tried what you suggested, and I've realised what is happening. The app does in fact flip back to SecureHub the very first time I open it after installing, but it then displays an error message (screenshot attached) which disappears after a short while, and then never re-appears when re-opening the app.

error

jaspreetsingh-citrix commented 1 year ago

Hi @tatham , This toast message is because SecureHub can't find the app's appID in its list of the enumerated apps from its configured store. After uploading .mdx on the CEM server, make sure the app in seen in SH's store page (if not seen, then refresh by pulling down Store view) Also, make sure the appID in the .mdx's manifest.xml matches the .bundleID of the installed app. If issue persists, can you please share .mdx and .ipa?

ShawnInTibco commented 1 year ago

Thanks @ShawnInTibco, I tried what you suggested, and I've realised what is happening. The app does in fact flip back to SecureHub the very first time I open it after installing, but it then displays an error message (screenshot attached) which disappears after a short while, and then never re-appears when re-opening the app.

error

@tatham That's it. Please check the run script via X-code and build.json in project path. Param "developmentTeam" in build.json and " APPIDPREFIX" in script should be the same as your teamID.

tatham commented 1 year ago

Thanks @ShawnInTibco and @jaspreet1 I've checked the app ID in the manifest.xml and I've checked the build.jason and mdx.json it is correct. I thought that it might be complicated by the fact that I'm using an enterprise distribution certificate and a wildcard provisioning profile, so I created a development certificate and a provisioning profile with the app ID that I have used for the sample app (I obviously can't use the Citrix app ID) but I'm still getting the same error message.

Is the store URL important? In a comment in the Citrix build script documentation it implies that it's not. However I have tried plain http and https versions of our store URL, and a version with port 4443, because that's what's required when logging in to our CEM server, but it makes no difference.

Some logging from the Console app: CTX MAM App Info: {"CTXMAMCore":"22.8.0+1"; "CTXMAMCompliance":"22.8.0+1"; "CitrixLogger":"22.8.0+1"; "CTXMAMNetwork":"22.8.0+3"; "CTXMAMLocalAuth":"22.8.0+1"; "CTXMAMAppCore":"22.8.0+1"; "CTXMAMContainment":"22.8.0+3"} {"Is MAMCore Debug Build?":"No"; "lib-ctxlogger":"2.3.9"} Device: iPad Air 2 (Wi-Fi+LTE) iOS: 15.7.3 [CTXMAMSharedDataNetworkSyncClientBase sendCommandToServer:error:]: Response to command GET_ALL_MAM_DATA_COMMAND failed with error 20. [CTXMAMTCPConnection getAllMAMDataForAppID:error:]_block_invoke: TCPConn: App not found in SH [CTXMAMTCPConnection getAllMAMDataForAppID:error:]_block_invoke: TCPConn: Failed to receive MAM data. ResponseDictionary: ( STATUS ) [CTXMAMSecureHubSharedData requestOverTCP]: No data received. [CTXMAMSecureHubSharedData getSharedMAMInfo:withError:]: Failed to get SH MAM data. [CtxEncryptionHelper encryptionKey]: Failed to get encyption key.

I'll create a Citrix support ticket so that I can send you any files or logs that you need for diagnosis.

ShawnInTibco commented 1 year ago

@tatham Store URL is not the point. Concern it only if you will distribute it to app store. Error "No Target Attributes provided for project object in project.pbxproj file. Invalid iOS platform!!!" is worth to be paid more attention. Did you open build path via x-code and config the "run script"? Please check the Readme.pdf and open the project, build app via x-code then you can get a wrapped .ipa & .mdx file in the "product" folder.

tatham commented 1 year ago

Thanks @ShawnInTibco The error about "Target attributes" is a concern, but I'm just running the code provided in the Citrix Sample app, so I was hoping you guys could tell me what the issue is ;-) (Worth noting that it happens first in the cordova prepare step.)

I wasn't actually running the build script in Xcode (must admit I missed that step, because it's after instructions to upload the (empty) MDX file to CEM in the ReadMe, which I assume is a mistake, unless this process is different to the process when using the MDX Toolkit. I was running a practically identical script after the cordova build was complete. Happy to add it into the Xcode project, but suspect the outcome will be the same.

FYI - I've created a Citrix Support ticket (81762557) which has a lot more detail of the steps I'm following, including command output and the config files, etc.

tatham commented 1 year ago

It looks to me like the script supplied in the pre-release Cordova iOS ReadMe only builds the MDX wrapper, it calls: "$TOOLKIT_DIR/CGAppCLPrepTool" SdkPrep -in "$CONFIGURATION_BUILD_DIR/$EXECUTABLE_FOLDER_PATH" -out "$CONFIGURATION_BUILD_DIR/$EXECUTABLE_NAME.mdx" which is, I think the same as the Cordova plugin does, except that it puts it in mdx/ios-debug.mdx

The additional script that I was using (based on the Citrix native iOS documentation) calls this to embed the ipa file: "${TOOLKIT_DIR}/CGAppCLPrepTool" SetInfo -in "${CONFIGURATION_BUILD_DIR}/${MDX_WRAPPER_FILENAME}" -out "${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME}-exported.mdx" -embedBundle "${IPA_FILE_PATH}"

ShawnInTibco commented 1 year ago

Hi @tatham. Sorry for delaying. Actually they are not the same. Run script in xcode will generate mdx file in the "product" folder-the same as ipa file. Not "mdx" folder.

The point: ipa file generated by "cordova build -ios" won't work for now(will fix the next version). You must use the ipa file build via xcode, and the mdx file beside ipa file.

Please build project via xcode.

tatham commented 1 year ago

Thanks @ShawnInTibco, that has resolved the issue. Some points:

but the good news is that the Citrix sample app is now working, and I can access a page on an internal server, so the microVPN is functioning as expected.

Interested to know what the difference is between the build that Cordova runs to generate an ipa file, and the one that Xcode runs when exporting an archive to produce an ipa file?

ShawnInTibco commented 1 year ago

@tatham Glad to see you have solved the problem. It's a known issue which will be fixed soon. Never mind it.