How to use a plugin without using ionic-native?

2019-02-20 15:13发布

I want add the cordova plugin: cordova-plguin-ms-adal. Because this plugin is not supported in the ionic-native. I don't know how to implement myself, so I open an issue and hope they will merge this plugin very soon.

In the meantime, I can't wait. So is there any way to use this plugin without using ionic-native?

I tried the following code in my home.ts, but failed to reach.

windows.plugins.Microsoft.ADAL.AuthenticationContext(s);

or directly

Microsoft.ADAL.AuthenticationContext(s);

Note: - Microsoft and ADAL are the namespaces of the plugin - AuthenticationContext is the function

1条回答
The star\"
2楼-- · 2019-02-20 15:30

You can use cordova plugin in ionic2 though the plugin is not supported by ionic-native. Add the required plugin to your project.

Open the file "Plugins.xml" and check for the target value under clobbers tag. In your case, it is Microsoft.ADAL.AuthenticationContext where Microsoft is the base class.

Open the ts file where you want to use the plugin.Use declare var Microsoft: any;under import as it is a base class. Then call the method as Microsoft.ADAL.AuthenticationContext.your_method()

查看更多
登录 后发表回答