How do I import Cordova plugin with Scripts inside C3?

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
[C2] [C3] Support C3 build service and Android 14
  • Hi, is anyone know how to correctly import Cordova plugins using JS ( files or in the event sheet)

    The project has been added to the Xcode, but the app can't find it since there is no working Import call from inside the app.

    Here is an example how developer of the plugin adding it in regular code, but adding it to cunstruct JS i see an error in the xcode console that this plugin is not found:

    import * as 'ProjectName' from 'cordova-plugin-yandex-ads/www/yandexads';

    await ProjectName.init({ ]}

    This line has been added to the js block OnStart of layout.

    Please help!

  • Just a guess, but do you need to add the plugin to the Cordova project using "cordova plugin add" then "cordova prepare" to build the xcode project?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi, i was stuck in calling the plugin from C3, but it's solved now.

    So to init this plugin i did that:

    if (typeof cordova !== 'undefined') {
     ('cordova-plugin-yandex-ads/www/yandexads');
    }
    
    // Initialize with your Yandex block IDs (get from Yandex dashboard)
    YandexAds.init({ 
    
    
    Inside Init there are a lot of code, and it is just taken from github of the plugin as is
    
    })
    

    Here are few notes about integrating plugin to the cordova ios project ( on Mac)

    Cordova should be installed by npm without sudo

    If your cordova doesn't run tasks without sudo, then permission should be added to the whole user folder ( i just did that, not sure what else can work)

    in terminal : Chown -r 'USER FOLDER'

    This was the main issue when adding plugin ( there were an errors like 'swift old version', 'no such module', pods errors etc.

    Just fixed permissions, installed cordova without sudo and everythig ran smooth.

    cordova platform add ios, cordova Plugin add 'Plugin name'.

    Inside the construct there are some js code to check cordova and event listeners. And it's been discussed here in forum

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)