'Using Unity Ads Cordova Plugin in Capacitor
I would like to use com-artemisoftnian-plugins-unityads3 Cordova plugin inside my Capacitor app. As you know that plugin is not one of Ionic Native plugins.
I added plugin name to capacitor.config.ts.
cordova:{
staticPlugins:[
'com-artemisoftnian-plugins-unityads3'
]
}
Plugin has function exports like UnityAdsInit, ShowVideoAd etc. However, if I use functions by importing it directly I get error Cannot find module “cordova/exec”.
import { UnityAdsInit, ShowVideoAd } from 'com-artemisoftnian-plugins-unityads3/www/UnityAds3';
UnityAdsInit('1234567890', true, true, (res) => {
console.log(res);
});
I found a way like to use plugin inse window object. But if I use plugin or exported function as window.UnityAdsInit() I get ‘window.UnityAdsInit’ is undefined error.
Actually I am not sure how I should use a Cordova Plugin in Capacitor app. How should I import or use Cordova plugin in Capacitor.
"@capacitor/core": {
"version": "3.4.0",
}
"@ionic/core": {
"version": "6.0.7",
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|