AdMob Integration

Trigger ads from your website

While Banner and Interstitial ads can be configured to show automatically, Rewarded Ads must be triggered by a user action on your website.

Prerequisites

Ensure you have enabled AdMob in the Integrations tab and configured a Rewarded Ad Unit ID.

Show Rewarded Ad

Call this when the user clicks a "Watch Ad" button.

window.FlutterWebView.postMessage(JSON.stringify({
    type: 'showRewardedAd'
}));

Know when the reward is earned

When the user finishes a rewarded ad that you started with showRewardedAd, the app tells your page with the ads.rewardEarned event of the Native bridge, with the reward amount and type. Subscribe after WebToAppBridgeReady; events are not replayed.

WebToApp.on('ads.rewardEarned', function (reward) {
  console.log('Earned', reward.amount, reward.type);   // reward = { amount, type }
});

Code running in a page can be changed by the person using it, so grant anything valuable on your server and not only in the browser.