you have to install "onesignal-cordova-plugin" as well to use it on capacitor app
try use this to import OneSignal from the plugin and try calling OneSignal.xxxxxxx
import OneSignal from 'onesignal-cordova-plugin';