Crossbow Admob Plugin
About
This project is a Crossbow Plugin that allows showing AdMob ads from Rust. Without worrying about the building, just download and use.
Supported features
Ad Format | Available |
---|---|
Banner | ❌ (probably doesn't work with NativeActivity) |
Interstitial | ✅ |
Rewarded | ✅ |
Rewarded Interstitial | ✅ |
Native | ❗ |
✅ = Works and tested — 🆗 = Works but may contain bugs — 🛠 = Under development — 📝 = Planned - ❌ = Not working - ❗ = Not planned to be implemented
Installation
Just add Rust dependencies like this:
[]
= "0.2.3"
[]
= "0.2.3"
And finally, add this to your Crossbow Android configuration:
[]
= ["com.crossbow.admob:admob:0.2.3"]
That's it, now you can start using AdMob ads!
If you want to publish or share your application to show real ads - configure custom APPLICATION_ID through Cargo.toml
file:
[[]]
= "com.google.android.gms.ads.APPLICATION_ID"
= "<YOUR ID HERE>"
# By default: ca-app-pub-3940256099942544~3347511713
Usage
First step is plugin initialization. In your rust project, you will need to initialize Crossbow
instance and then get Android plugin:
use *;
let crossbow = new;
let admob: AdMobPlugin = crossbow.get_plugin?;
// Initialize AdMob Service
admob.initialize.unwrap;
To show Interstitial Ad, use following code (remember, currently there's no async API for this plugin - so load
and show
functions should be called as soon as Sinals
received or is_initialized()/is_interstitial_loaded()
checked):
admob.load_interstitial.unwrap;
admob.show_interstitial.unwrap;
The result will be like this:
To read signals:
if let Ok = admob.get_receiver.recv.await
Complete documentation you can find here.
Thanks and inspiration
This Plugin was initially inspired by godot-admob-android.