iOS InApp Unity Documentation - yanivav/Documentation GitHub Wiki
Last SDK Version: 2.4.2
This document describes the basic procedure for integrating StartApp In-App Ads into your Unity applications for iOS.
After this simple integration process, StartApp In-App Ads enables you to reap the benefits of StartApp's In-App monetization products, which maximize the revenue generated by your application. All this profit-making is achieved with minimal effort and minimal interference with your users’ experience.
NOTES:
- To build your app with StartApp SDK you must have XCode 4.4.1+
- The code samples in this document can be copy/pasted into your source code
- When submitting your application to the App Store,do not forget to update your "IDFA Settings"
- If you have any questions, contact us via [email protected]
##Step 1, Adding the SDK package to your Unity project
In order to add StartApp SDK to your application please follow the following steps:
1. Unzip the SDK files to a temporary folder
2. Import StartAppiOSUnitySDK-x.x.x.unitypackage as a Custom Package (or drag and drop it to your "Assets" folder under the "Project" Window)
3. Import all the package's items by pressing "All" and then "Import"
##Step 2, Updating your StartApp data file
Update the StartAppDataiOS.txt_ (in the Assets/Resources folders) as follows:
1. Add your StartApp Account ID after developerId=
2. Add your StartApp Application ID after applicationId=
You can find your Account and Application IDs in the developers’ portal.
After logging in, your account ID will be displayed at the top right-hand corner of the page:
To find your application ID, click on the "Apps and Sites" tab on the left pane and choose the relevant ID from your app list:
You can choose to show an interstitial ad in several locations within your application. This could be upon entering (onCreate), between stages, while waiting for an action and more.
Add the following code to the appropriate place or places in which you would like to show the ad:
1. Load the ad
void Start () {
#if UNITY_IPHONE
StartAppWrapperiOS.loadAd();
#endif
}
2. Show the ad
StartAppWrapperiOS.showAd();
You can show a specific type of interstitial ad, as well as getting callbacks events. For detailed instructions please refer to the Advanced Usage.
##Showing the Splash Ad A Splash Ad is a full-page ad that is displayed immediately after the application is launched. A Splash Ad first displays a full page splash screen that you define (as described below) followed by a full page ad.StartApp SDK provides two modes for displaying Splash screens:
Splash Screen Mode | Description |
---|---|
User-Defined Mode (default) | Using your application's default splash image, with a loading animation |
Template Mode | StartApp SDK provides a set of pre-defined templates in which you can place your own creatives, such as application name, logo and loading animation. for more details, please refer to the "Advanced Manual" |
####Adding the Splash Screen
Simply call showSplashAd()
in your Start()
method:
void Start () {
#if UNITY_IPHONE
StartAppWrapperiOS.showSplashAd(); // show splash ad
#endif
}
Please note that you should attach the script to an object which is being allocated upon application's launch (for example, "Main Camera").
If you wish to customize or use a different splash screen, please refer to the Advanced Usage.
##Return Ads The **Return Ad** is a new ad unit which is displayed once the user returns to your application after a certain period of time. To minimize the intrusiveness, short time periods are ignored. For example, the Return Ad won't be displayed if the user leaves your application to take a short phone call before returning.Return ads are enabled and activated by default. If you want to disable this feature, simply call disableReturnAd()
in your Start()
method:
void Start () {
#if UNITY_IPHONE
StartAppWrapperiOS.disableReturnAd(); // disable return ads
#endif
}
Please note that you should attach the script to an object which is being allocated upon application's launch (for example, "Main Camera").
##Showing Banners
To add a banner to your application add the following code to your Start()
method:
void Start () {
#if UNITY_IPHONE
StartAppWrapperiOS.addBanner(StartAppWrapperiOS.BannerPosition.BOTTOM);
#endif
}
Parameters
BannerPosition - position of the banner. Can receive one of the following:
StartAppWrapper.BannerPosition.BOTTOM
StartAppWrapper.BannerPosition.TOP
You can change the banner position and size, as well as getting callbacks events. For detailed instructions please refer to the Advanced Usage.
##Step 5, Build Your Unity Project
The first time you build your unity project with StartApp SDK, make sure to use "Build and Run" (instead of "Build"). Once completed, Unity will create and load an XCode project. You will notice a few errors. That's ok. Please follow the following steps to include additional necessary frameworks, then re-build your project.
- Select your application project to bring up the project editor
- Select your application target to bring up the target editor
- Select the Build Phases tab and disclose the "Link Binary with Libraries" phase and click the plus button in that phase
- Add the following frameworks:
CoreTelephony.framework
StoreKit.framework
AdSupport.framework
##Advanced Usage For advanced usage, please refer to the ["Advanced Usage"](unity-iOS-advanced-usage) section. ##Updating your IDFA Settings When submitting your application to the App Store you need to update its "Advertising Identifier (IDFA)" settings in order to comply with Apple advertising policy.NOTE: from now make sure to use the "Append" option (instead of "Replace") every time you "Build and Run" your project, so all the above changes will be kept.
On the "Advertising Identifier" section:
1 Choose "Yes" on the right pane
2 Opt-in the "Serve advertisements within the app" checkbox
3 Opt-in the confirmation checkbox under "Limit Ad tracking setting in iOS"