Ms adal not working with capacitor (ionic 5) Help needed pls :/

Hello,

I’m trying to create an ionic application using capacitor not cordova to avoid this problem:

ITMS-90809: Deprecated API Usage - Apple will no longer accept submissions of new apps that use UIWebView as of April 30, 2020 and app updates that use UIWebView as of December 2020. Instead, use WKWebView for improved security and reliability. Learn more (https://developer.apple.com/documentation/uikit/uiwebview).

PS: I tried adding in config xml what is suggested but I still get the warning.

The plugin works fine with cordova but with capacitor it trigger an error :confused:

Connection to daemon was invalidated
To Native Cordova -> ADALProxy acquireTokenAsync ADALProxy1980932256 [“options”: [***, 1, https://graph.windows.net/, ******, ****, , ]]

I need this ASAP , we have a deadline coming (04/05/2020) and I didn’t find a solution, any help ?


Ionic:

Ionic CLI : 6.6.0 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.803.26
@angular-devkit/schematics : 8.3.26
@angular/cli : 8.3.26
@ionic/angular-toolkit : 2.2.0

Capacitor:

Capacitor CLI : 2.0.1
@capacitor/core : 2.0.1

Utility:

cordova-res (update available: 0.12.2) : 0.9.0
native-run (update available: 1.0.0) : 0.3.0

System:

NodeJS : v12.14.1 (/usr/local/bin/node)
npm : 6.13.4
OS : macOS Catalina

So you are using Capacitor, which drops the UiWebView, means you have a Plugin installed, which uses UiWebView. Open xCode and search for UiWebView. Where do you find Results in Code?

I need capacitor to surpass the UiWebView problem , I don’t know if it cause the problem with Ms adal plugin, or maybe I need to install the webview plugin (https://ionicframework.com/docs/native/ionic-webview) in my project not sure …

First: No you don’t need to switch to Capacitor because this. Cordova has a Workaround too, BUT if possible, switching to Capacitor is very good in my opinion, so!

Then: Is this the Plugin you use? I just have a look into it and as you can see in your last Finding: Yes, they are using the UiWebView and this cause the Problem. Also this Plugin seeems to be archived and unmaintained, so won’t be updated i think.

The workaround (https://cordova.apache.org/howto/2020/03/18/wkwebviewonly.html) didn’t work for me, I don’t know why, I keep getting the warning error.

Yes that’s the plugin , I don’t know if there is any other plugin to implement the azure auth with ionic.
I tried MSAL but it’s not compatible with ionic (mobile : ios/android), B2C auth is available only with entreprise edition …

Look: The Adal Plugin uses the UiWebView. So it doesn’t matter if you youse Capacitor or Cordova, the Error will continue, as long as you use this Plugin. The Workaround from Cordova does work, but of course they can’t change other Plugins (Capacitor either). So if there isn’t a working Plugin, try to fork the one you are using at the Moment and try if you can replace the UiWebView with the WkWebView

Thanks for the explanation , it’s more clear now :smiley: , but I don’t think that i will be able to replace UiWebView with the WkWebView , I don’t know how things work exactly :frowning:

The Error is fixed in the ADAL Framework like 2 years ago (See here). The Plugin you use has the Framework added directly, so i think you just need to replace it.

In this Step, replace with Cocoapods would be better

I will try to replace it , although i’m not good with Objc .

I’m biased because I work for Ionic, but hear me out.

This situation is exactly why we built Ionic Auth Connect. Microsoft has decided to stop supporting the Cordova plugin for MS ADAL and as is the case with all software, over time it gets out of date and issues like this arise.

The honest answer is that paying for Auth Connect is a lot more affordable than spending hours of developer time trying to get this fixed. Also, by working on this authentication issue, you’re not working on the unique parts of your app/business - the parts that matter. If this is a serious deadline and you’re part of a team at a company, consider sending me a note: matt.netkow@ionicframework.com. I can put you/the team in touch with the right folks to see what options are.

2 Likes

hey i tried everything to run ADAL in capacitor, I creating custom plugin for capacitor but something wrong in capacitor to connect code, cordova is best option to work with ADAL cordova adal plugin you can use capacitor custom plugin i tied for testing .

also you can change pod dependance into

Podfile -> pod ‘ADAL’, ‘4.0.5’

and

<key>LSApplicationQueriesSchemes</key>
<array>
     <string>msauth</string>
     <string>msauthv3</string>
</array>

@bhbhandari hey thank you for your reply , I tried to update the adal to last version too

repo : https://github.com/fradali/azure-activedirectory-library-for-cordova/tree/adal-new/src/ios

The app is building but when I run the code of auth I got some problems :confused:

Connection to daemon was invalidated
unrecognized selector sent to class 0x204e03ff0
2020-05-02 04:43:14.863900+0200 App[4029:2655655] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: '+[NSString adIsStringNilOrBlank:]: unrecognized selector sent to class 0x204e03ff0

tried to figure out what’s the problem:

1- this block declaration is not a prototype

- (void)runInBackground:(void (^)())block
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
}

2- Enqueued from com.apple.main-thread

- (void)acquireTokenAsync:(CDVInvokedUrlCommand *)command
{
    [self.commandDelegate runInBackground:^{
.
.
.

Hi Matt,
I understand Auth Connect is Enterprise grade (and priced).
So I wanted to ask, for indie devs that make one/two apps per year, are there any more affordable choices?
Thanks!
Gustavo.

Hi Matt, we are working on a project for a customer that needs Azure AD authentication. We are fairly new to Ionic, but have built some apps. An Enterprise Plugin would definitely be an option. Is there any chance you can set me up with someone to clear our doubts? Reading the documention, it is not clear for me how all this works together and the effort we’ll need to implement it.

Best regards, Ariel

Hi Ariel - absolutely. Please send an email to netkow@ionic.io and I’ll help clarify any questions you have. Thanks!