WP - Use Interstitial Ads
Visual Basic tutorials for UWP apps.
1 post
Page 1 of 1
The following code can be used to include Interstitial Ads (Video adverts) in your apps.
This is a great way of monetizing your apps in various ways, such as:
To allow users to earn credits for use in your game
Unlock special features/area/modes of your app
Just to help earn a little something to help fund your app
First you will need to install and include the Microsoft Store Engagement and Monetization SDK
Now in your project open "Reference Manager" -> Expand the "Universal" tab -> Select "Extensions" -> Tick the box next to "Microsoft Advertising SDK for XAML"
Now your app is ready to deliver ads.
Simply include the following code with events in to whichever page of your app you wish to show ads in.
A more detailed explanation of how to use Interstitial ads and how to create your own App and AdUnit Id's can be found by clicking the following link:
https://msdn.microsoft.com/en-gb/window ... ladsxaml10
Hope this is useful to someone
This is a great way of monetizing your apps in various ways, such as:
To allow users to earn credits for use in your game
Unlock special features/area/modes of your app
Just to help earn a little something to help fund your app
First you will need to install and include the Microsoft Store Engagement and Monetization SDK
Now in your project open "Reference Manager" -> Expand the "Universal" tab -> Select "Extensions" -> Tick the box next to "Microsoft Advertising SDK for XAML"
Now your app is ready to deliver ads.
Simply include the following code with events in to whichever page of your app you wish to show ads in.
Code: Select all
Dim MyVideoAd As New InterstitialAd()
Code: Select all
Private Sub ShowVideoAd()
' Define ApplicationId and AdUnitId.
' Test values are shown here. Replace the test values with live values before submitting the app to the Store.
Dim MyAppId = "d25517cb-12d4-4699-8bdc-52040c712cab"
Dim MyAdUnitId = "11389925"
AddHandler MyVideoAd.AdReady, AddressOf MyVideoAd_AdReady
AddHandler MyVideoAd.ErrorOccurred, AddressOf MyVideoAd_ErrorOccurred
AddHandler MyVideoAd.Completed, AddressOf MyVideoAd_Completed
AddHandler MyVideoAd.Cancelled, AddressOf MyVideoAd_Cancelled
' Pre-fetch an ad 30-60 seconds before you need it.
MyVideoAd.RequestAd(AdType.Video, MyAppId, MyAdUnitId)
End Sub
Code: Select all
Private Sub MyVideoAd_AdReady(sender As Object, e As Object)
If (InterstitialAdState.Ready) = (MyVideoAd.State) Then
MyVideoAd.Show()
End If
End Sub
Code: Select all
Private Sub MyVideoAd_ErrorOccurred(sender As Object, e As AdErrorEventArgs)
'Whatever you want to happen if the ad has an error
End Sub
Code: Select all
Private Sub MyVideoAd_Completed(sender As Object, e As Object)
'Whatever you want to happen when the video has finished playing
End Sub
Code: Select all
Then whenever you wish to show a video ad to the user just call:Private Sub MyVideoAd_Cancelled(sender As Object, e As Object)
'Whatever you want to happen if the user cancels/closes the video before it has finished
End Sub
Code: Select all
This uses test values for the MyAppId and MyAdUnitId but you will need to change these before you publish your app to the store.ShowVideoAd()
A more detailed explanation of how to use Interstitial ads and how to create your own App and AdUnit Id's can be found by clicking the following link:
https://msdn.microsoft.com/en-gb/window ... ladsxaml10
Hope this is useful to someone
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023