This is an example project for implementing the Unity Ads SDK in a SpriteKit game using Swift
Planet illustration provided by NASA - Original image by ESA/Hubble (M. Kornmesser) - https://www.spacetelescope.org/
#How to integrate Unity Ads into your project
- Download the Unity SDK from https://github.com/Applifier/unity-ads-sdk
- Down the zip file
- Unzip the project, and locate
UnityAds.framework
andUnityAds.bundle
- Import
UnityAds.framework
andUnityAds.bundle
into your project
- Drag and drop the files into your project
- Select the box next to "Copy
- Make sure all of the following dependancies are enabled in your project
CoreMedia.framework
, CoreTelephony.framework
,
SystemConfiguration.framework
, AdSupport.framework
,
CFNetwork.framework
, StoreKit.framework
- Add a bridging header for
UnityAds.framework
####In Your AppDelegate:
- Create a shared instance of Unity ads
static let unityAds = UnityAds()
####In Your Root View Controller
- Initialize the SDK
UnityAds.sharedInstance().startWithGameId("YOUR_GAME_ID", andViewController: self)
- Implement unityAdsVideoCompleted callback
func unityAdsVideoCompleted(rewardItemKey: String!, skipped: Bool) {if (!skipped) {//Provide ingame reward}}
- Implement a method for displaying ads
UnityAds.sharedInstance().canShowZone(placement)) { UnityAds.sharedInstance().show() )
####In Your SKScene or Any ViewController
- Call for a rewarded ad
let vc = self.view!.window!.rootViewController as! YourRootViewController
vc.playAd("rewardedVideo")