Promise vs Callback - appfeel/admob-google-cordova GitHub Wiki
Promise vs Callback
All methods in this plugin return promises, both for Capacitor and Cordova versions, which are resolved when the plugin has done the asked action. However, Cordova also allows passing callback functions as parameters, which will be called after the plugin has done that same asked action. The following code will have the same behaviour:
Promise
try {
const data = await admob.createBannerView(options);
console.log('Banner created succesfully returning:', data);
} catch (err) {
console.log('Error creating banner:', err);
}
Callback
const onSuccess = (data) => {
console.log('Banner created succesfully returning:', data);
}
const onFailure = (err) => {
console.log('Error creating banner:', err);
}
admob.createBannerView(options, onSuccess, onFailure);