SDK 5 Upgrade guide
Adverty SDK upgrade guide from SDK 4 to 5
This guide will help you with the update process. However, every project is set up differently thus the instructions won’t fit all games. We believe most developers will be able to get some insights and help in the process by reading through this guide.
Major differences
- Now Ad Surfaces has a free ratio. This means a publisher can create placements in any size they want. Adverty will try to find an ad with the correct ratio; however, all ads that fill at least 50% of the Ad Surface will be allowed, and an ad will, in that case, be padded with black borders. We recommend using the standard Ad sizes provided in the Adverty5/Example/Prefab folder to minimize the black borders.
- The same ad can be activated on multiple AdPlacements at the same time. You can get 2 OnAdPlacementActivated callbacks but only one OnPaidCallback(double price).
- Clicks on Android and iOS open a browser in the app context and the user does not leave the app unless the device does not support CustomTabs on Android or SafariView on iOS.
- The minimum Android API that Adverty can launch is API 24 (Android 7.0); however the app can be run with a lower Android API. Adverty will not start on older devices.
- The minimal iOS version that Adverty can launch is iOS 12.
Steps for Upgrade
- Import new Adverty SDK5 into your project where SDK 4 is still present (they can co-exist).
- Run our helper script to find and update all AdUnits (SDK4) to new AdPlacements (SDK5).
- Upgrade script will find and replace old InPlayUnit and InMenuUnit with new AdPlacement scripts. Prefabs also will be patched.
- The script will open all scenes that contain AdUnits simultaneously to refer to all GameObjects that will be affected.
- If old units use Adverty resources (textures, meshes, materials, prefabs) they will be moved into the Adverty5/LegacyResources folder to keep references. These resources are not required for the SDK itself so feel free to update to your own meshes, materials and textures.
- Adverty textures also will be updated to RGBA32 format (required for SDK5).
- Replace the old InitializeAdvertySDK script with Adverty Loader. Since Adverty Loader script loads and control context of Adverty SDK, it makes the object work as a DontDestroyOnLoad object, so do not place it on camera or other objects which should not be shared in-between scenes.
- Set Adverty5 settings similar to SDK4 through the Tools->Adverty5->Settings tab. Note: Please make sure to use a new API Key for the upgraded project.
- Delete the old Adverty folder and keep the new Adverty5 folder. You can also delete the AdvertyUpgrade4to5.cs script.
- Restart Unity. This is necessary because Unity requires restart to unload deleted plugins.
- Enjoy!
Additional Steps for URP based projects:
- Download URP package
- Add AdvertyRenderPassFeature to your renderer:
- Go to the Project settings ->Graphics and add AdvertyRenderPassFeature for each Renderer that uses in your project:
- Press Add Renderer Feature button
- Choose Adverty Render Pass Feature
- Enjoy your URP project with Adverty!
- Go to the Project settings ->Graphics and add AdvertyRenderPassFeature for each Renderer that uses in your project:
Introduced callbacks
- OnPaidCallback(double price)
This is a session-level callback that triggers when an ad has been paid. It returns the price in CPM. To convert it to Dollars, divide it by 1000. The reported revenue is estimated and might differ slightly from the monthly invoice statement. Look at Adverty5/Scripts/Library/AdvertySDKLoader for example usage. - OnPlacementRegistered
AdPlacement callback triggers when an AdPlacement is successfully registered to AdvertySDK. Look at Adverty5/Example/AdReceivingValidation, for example usage. - OnPlacementRegistrationFailed
AdPlacement callback triggers when an AdPlacement fails to register to AdvertySDK. Look At Adverty5/Example/AdReceivingValidation, for example usage. - OnAdPlacementActivated
AdPlacement callback triggers when an AdPlacement gets activated and shows an ad. The ad on an AdPlacement might not be unique to that AdPlacement since the same ad can be activated on multiple AdPlacements simultaneously. Look at Adverty5/Example/AdReceivingValidation, for example usage.
Another common use case is to detect if Adverty did have an ad for the game
- SDK doesn’t have a callback for this as it is designed to continuously try to fill the AdPlacements created. Thus, even if no ad is available at the current moment, it might have ads very soon. To work in mediation/waterfall flows, an example of how to determine if SDK did serve an ad to placement is added in Adverty5/Example/AdReceivingValidation script.