Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
903 views
in Technique[技术] by (71.8m points)

cordova - How to use a plugin without using ionic-native?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...