I’ve written a post and pieced some code together here for an AdMob Manager that supports Banners and Interstitial Ads with MonoGame and works on both Android and iOS. It’s a single class that’s essentially an amalgamation of some samples, stack overflow answers and some lessons learned from trial and error.
Since this bit of code has been working so well for Space Esc8bit and Chaotic Workshop, I figured it’d be worth writing a post and posting some code.
I hope this helps! If you like it give me a follow or let me know and I’ll try to post more things like this!
While implementing on Android though, I did encounter an issue which, thanks to a helpful community member, was resolve via a workaround. Not sure if you encountered it or not, but on Android there’s a problem unless you use SingleTop as your launchmode.
Hmm, that’s interesting. My games are set to ‘LaunchMode = LaunchMode.SingleInstance’ and they’ve worked on the 3 android devices i’ve tested. What was the issue with having it set to SingleTop?
The issue was with an interstitial ad. If you task switch while it was showing, either by tapping the home button or clicking the ad, you couldn’t return to the game. I was able to reproduce this in a simple project, outside of any of my code. At the top of the linked post you can find some code to reproduce this in some pastebin links.
The issue seemed to be resolved when setting the LaunchMode to SingleTop through my initial investigation, though I haven’t done anything more thorough as I’ve set aside the ad-enabled feature to focus on the paid release first… I’m kinda wanting to finish this and work on other projects, so going around in circles with the ad stuff was getting tiresome
It was also possible that this presented itself solely on the emulator as I didn’t have a physical device at the time, though KakCAT did say that they could reproduce a problem, just a somewhat different one.
Admob is no more working in Visual Studio. I installed the Xamarin.Firebase.iOS.AdMob NuGet package in my project.
But I get this error message when I run my project:
/Users/Steven/Desktop/Interstitial_Ads/Interstitial_Ads/MTOUCH: Error
MT0065: Xamarin.iOS only supports embedded frameworks when deployment
target is at least 8.0 (current deployment target: ‘7.0’; embedded
frameworks:
‘/Users/Steven/Library/Caches/XamarinBuildDownload/FInstncID-3.1.1/Frameworks/FirebaseInstanceID.framework,
Security,
/Users/Steven/Library/Caches/XamarinBuildDownload/FAnlytcs-5.0.1/Frameworks/FirebaseAnalytics.framework,
AddressBook, AdSupport, CoreGraphics, StoreKit, SystemConfiguration,
/Users/Steven/Library/Caches/XamarinBuildDownload/FAnlytcs-5.0.1/Frameworks/FirebaseCoreDiagnostics.framework,
/Users/Steven/Library/Caches/XamarinBuildDownload/FAnlytcs-5.0.1/Frameworks/FirebaseNanoPB.framework,
/Users/Steven/Library/Caches/XamarinBuildDownload/FAdM-7.31.0/Frameworks/frameworks/GoogleMobileAds.framework,
AudioToolbox, AVFoundation, CFNetwork, CoreMedia, CoreMotion,
CoreTelephony, CoreVideo, GLKit, MediaPlayer, MessageUI,
MobileCoreServices, OpenGLES, QuartzCore, JavaScriptCore,
SafariServices, WebKit’) (MT0065) (Interstitial_Ads)
After that, I changed the current deployment target to ‘8.0’ but then I get much more(59 messages) error messages.
What is wrong? Why can I not use the Xamarin nuget package in my project?