Download the PHP package bhargavdetroja/nativephp-google-mobile-ads without Composer
On this page you can find all versions of the php package bhargavdetroja/nativephp-google-mobile-ads. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bhargavdetroja/nativephp-google-mobile-ads
More information about bhargavdetroja/nativephp-google-mobile-ads
Files in bhargavdetroja/nativephp-google-mobile-ads
Package nativephp-google-mobile-ads
Short Description Google Mobile Ads (AdMob) plugin for NativePHP Mobile — Banner, Interstitial, Rewarded, and App Open ads on Android and iOS.
License MIT
Homepage https://github.com/bhargavdetroja/nativephp-google-mobile-ads
Informations about the package nativephp-google-mobile-ads
NativePHP Google Mobile Ads
Add Google AdMob ads to your NativePHP Mobile app in minutes. No Kotlin, no Swift, no Gradle edits.
Works with any frontend — Livewire, React, Vue, Alpine.js, or plain JavaScript.
Supports Banner, Interstitial, Rewarded, Rewarded Interstitial, and App Open on Android and iOS.
Requirements
- PHP 8.2+
- Laravel 12+
- NativePHP Mobile 3.x or 4.x
- An AdMob account (free)
NativePHP Mobile v4: this plugin works unchanged under v4's web view — the bridge functions, events, and Blade
<x-google-ads::banner>component all keep working exactly as they do on v3. SuperNative-nativeNativeComponentscreens are not required to use this plugin.
Installation
1. Install the package
2. Publish the config
3. Add your AdMob IDs to .env
Not ready for real IDs? Leave the values empty — when
APP_ENVis notproduction, the plugin automatically uses Google's official demo IDs so you always see real test ads.
4. Run native install
Both App IDs are injected into native configs automatically from your .env. No vendor files to edit.
Configuration
config/google-mobile-ads.php gives you full control over ad placements, test mode, and the kill-switch.
Kill-switch
Disable all ads globally with one env key — useful for premium users or A/B testing.
Test mode
Automatically on when APP_ENV != production. Override if needed:
When active, Google's official demo IDs are substituted automatically — your real Ad Unit IDs are never used.
Named slots
Slots are named ad placements defined in your config. They support different IDs per platform:
Showing Ads
Option A — Blade component (banner only)
Drop a banner anywhere in your Blade views. Show/hide is handled automatically when the component mounts and unmounts.
Option B — PHP Facade
Option C — JavaScript (React, Vue, Alpine, plain JS)
The JS bridge accepts raw ad unit IDs. Slot resolution and test-mode substitution happen server-side via the Blade component or PHP Facade.
Pass the resolved ID from Blade so test-mode is respected:
Listening to Events
In JavaScript — works with any framework
React:
Vue:
In PHP — standard Laravel events
Register in AppServiceProvider:
Livewire:
All Events
| Event | Properties | When it fires |
|---|---|---|
AdLoaded |
$adType, $adUnitId |
Ad is ready to show |
AdFailedToLoad |
$adType, $adUnitId, $errorCode, $errorMessage |
Ad failed to load |
AdOpened |
$adType |
Full-screen ad appeared |
AdClosed |
$adType |
Full-screen ad was dismissed |
AdImpression |
$adType |
Ad recorded an impression |
AdClicked |
$adType |
User tapped the ad |
RewardEarned |
$rewardType, $rewardAmount |
User completed a rewarded ad |
$adType values: banner, interstitial, rewarded, rewarded_interstitial, app_open
Going to Production
- Add your real Ad Unit IDs to
.env. - Set
APP_ENV=production— test mode turns off automatically. - Run
php artisan native:install --force. - Build your release:
php artisan native:run android/php artisan native:run ios.
Troubleshooting
App crashes on iOS launch
ADMOB_IOS_APP_ID is missing or wrong in your .env. Set it to your real iOS App ID and run php artisan native:install --force.
Ads not showing in development
Test mode is likely on — this is correct behaviour. You should still see Google demo ads. If you see nothing, make sure you called initialize() and that you're on a real device (not iOS Simulator).
unknown slot exception
You passed a slot name that isn't defined in config/google-mobile-ads.php. Either add it to slots, or pass a raw ca-app-pub-... ID directly.
Interstitial/Rewarded "not loaded" error
You must call load*() and wait for the AdLoaded event before calling show*().
iOS Simulator shows no ads Google Mobile Ads SDK does not support iOS Simulator. Use a real iPhone.
Android emulator shows no ads The AVD must use a Google APIs system image — not plain Android or Google Play.
Validate plugin setup
License
MIT