You can download or update Xcode from the App Store, or sign in to the Apple Developer Resource Center to download a specific version.
Topon SDK version 6.5.86 and later supports SPM integration
We provide the following two ways to import the Topon iOS SDK:
Click here to go to the SDK Download Center. You can follow the steps in the images below to select and generate the SPM code according to your needs.
- When selecting platforms, you may find that some platforms do not support SPM. In this case, we recommend importing the corresponding Adapter and third-party SDK by manually downloading the offline packages.
- After generating the relevant code, please do not leave the SDK Download Center webpage, as the subsequent integration steps will also use its contents.



Open the project and select File > New > Package.. in Xcode.

Select Library, then click Next.

Click Next directly, then save the Library.

Change the name of the local SPM library, and place the generated local SPM library folder in the project root directory.

Open the project, select the main project, and choose File > Add Files to "XXXDemo" to link the local SPM folder to the project. After it is added, the main project will contain an SPM dependency library.



Add the SPM dependency to the main project.




Open Package.swift. Copy all .package(url: "xxx", exact:"xxx") and .product(name: "xxx", package: "xxx") entries from the code generated by the SDK Download Center into the specified section of the local Package.swift file.

Fetch the SPM dependencies.

Open the project and select File > Add Package Dependencies... in Xcode.

Enter the SPM repository URL provided by Topon.
Select the version required by the SDK. When the release version must be locked exactly, select Exact Version.
Select the required Package products and add them to the App Target that uses the SDK. If an Extension also uses the SDK directly, add them to the corresponding Target as well.

Add the required Adapters in the same way. If an Adapter's Package already includes the products it depends on, follow the actual dependency relationship and SDK integration instructions to avoid adding them repeatedly.
After adding them, confirm the versions under Package Dependencies in the project, and confirm that the required products are associated under General > Frameworks, Libraries, and Embedded Content in the Target.


The SKAdNetwork ID for UnityAds is different for every project. If you select this ad platform, use the value generated in the UnityAds console and check it in the UnityAds management console.
Return to the "SDK Download Center" webpage opened above, and add the contents listed in the "SKAdNetwork IDs code" section to your Info.plist file. Refer to the image below:

Return to the "SDK Download Center" webpage opened above, or copy the code below directly, and add the contents listed in the corresponding section to your Info.plist file. Refer to the image below:

Starting with iOS 14.5, apps can access the user's IDFA data and serve targeted ads only after obtaining the user's explicit permission.
IDFA is unavailable before the app uses the App Tracking Transparency framework to request tracking authorization from the end user. If an app does not make this request, the IDFA returned is a string consisting entirely of zeros.
<key>NSUserTrackingUsageDescription</key>
<string>Change this to the permission request description you want users to see. It can be localized.</string>
After iOS 10, when the Allow Arbitrary Loads in Web Content key exists, the Allow Arbitrary Loads setting is ignored.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Add this key only if you selected the AdMob platform. For more information, please go here.
<key>GADApplicationIdentifier</key>
<string>Your GADApplicationIdentifier </string>
<!-- Example format for the value above: ca-app-pub-9488501426181082~7219780494 -->
Before integrating this section, you should understand that you need to explain to users in detail the relationship between the system permissions required by the Topon SDK and each business function, and explain when the permission request will be made.
For the optional system permissions that can be requested by the Topon iOS SDK, you can refer to the table below to learn more about the relationship between each permission and the relevant business functions, as well as when to request it. Not requesting a relevant permission will affect its corresponding function, so configure it reasonably based on your actual business needs.
List of iOS application permissions:
| Permission | Function | Use and purpose | When it is called |
|---|---|---|---|
| NSUserTrackingUsageDescription | [Optional] Obtain the device identifier to identify device information | Serve ads and prevent fraud | The developer calls it when invoking an SDK function that requires this permission. Request it when the developer needs to adjust ad monetization strategies and data analysis services based on device information. |
After understanding the above, you need to use App Tracking Transparency to request app tracking authorization from users.
- Before using the method below, you need to set the NSUserTrackingUsageDescription key value in the Info.plist file. Click here for details.
- If your project needs to support GDPR or Google UMP, go here for configuration. You do not need to add the code below.
// Import header files
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>
#import <AnyThinkSDK/AnyThinkSDK.h>
// If using AppDelegate
@implementation AppDelegate
- (void)applicationDidBecomeActive:(UIApplication *)application {
if (@available(iOS 14, *)) {
// iOS 14
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
}];
} else {
// Can be obtained directly
NSString * idfaStr = [ASIdentifierManager sharedManager].advertisingIdentifier.UUIDString;
}
}
@end
On iOS 15 and later, this API displays the authorization prompt only when the app state is
UIApplicationStateActive. If another permission request is waiting for user confirmation, the authorization prompt will not be displayed.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//....
// Enable logs
[ATAPI setLogEnabled:YES];//Turn on debug logs
//....
return YES;
}
You can check whether the SDK integration for each ad platform is working correctly based on the logs output by this method.
Please note that this function must be removed from the release build.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//....
// Enable logs
[ATAPI setLogEnabled:YES];//Turn on debug logs
// After enabling logs, call the integration check method
[ATAPI integrationChecking];
return YES;
}
Example output:

⚠️ Important (compliance required)
The initialization method must satisfy all three of the following conditions at the same time. None of them can be omitted:
- Call it after the user agrees to the privacy policy. If your app needs to display the privacy policy and request the user's consent at first launch, refer to Topon Privacy Policy and Privacy Compliance.
- Do not call it early during app launch. Do not place it in startup paths such as
application:didFinishLaunchingWithOptions:orviewDidLoad.- Use it as a prerequisite for ad loading. In the same call chain, complete initialization first and then execute load; do not continue loading ads when initialization has not succeeded.
💡 Tip
- Can be called repeatedly: Initialization is idempotent. After the SDK has been initialized, calling it again returns success directly. Therefore, it is safe to place initialization before every ad load, and you do not need to add your own "initialize only once" flag.
- AppID / AppKey: Obtain these from the app information in the Topon console. iOS and Android use different values; do not mix them.
- Log switch:
setLogEnabled:outputs IDFA and device information and is intended only for integration debugging. Wrap it with#if DEBUG; it must not be included in the Release build.
#import <AnyThinkSDK/AnyThinkSDK.h>
@interface AdManager : NSObject
- (BOOL)configureAdSDK;
- (void)loadAd;
@end
@implementation AdManager
/// Initialize the ad SDK
/// Idempotent: repeated calls after SDK initialization return success directly, so this can safely be placed before every ad load
/// @return Whether initialization succeeded; do not continue loading ads when NO is returned
- (BOOL)configureAdSDK {
#if DEBUG
// Outputs IDFA and device information for debugging only; it must not be included in the Release build
[ATAPI setLogEnabled:YES];
#endif
NSError *error = nil;
BOOL success = [[ATAPI sharedInstance] startWithAppID:@"Your AppID"
appKey:@"Your AppKey"
error:&error];
if (!success) {
NSLog(@"[Topon] SDK initialization failed domain=%@ code=%ld msg=%@",
error.domain,
(long)error.code,
error.userInfo[@"msg"]);
}
return success;
}
/// Load ads
/// Prerequisite: the user has agreed to the privacy policy
- (void)loadAd {
// Initialization is a prerequisite for load: initialize first, then load after it succeeds
if (![self configureAdSDK]) {
return;
}
#if DEBUG
// Third-party platform integration self-check, for debugging only and not required for initialization
[ATAPI integrationChecking];
#endif
// Execute ad loading after initialization succeeds
// [self.bannerView loadAd:@"Your PlacementID"];
}
@end