Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

These instructions give an overview of integrating the MobileFuse SDK with your iOS app.

Current Version

Integration Steps Overview

Step 1. Download the MobileFuse iOS SDK

The MobileFuse SDK is distributed on CocoaPods.

Podfile setup

Update your project’s podfile to include the MobileFuse SDK

source 'https://github.com/CocoaPods/Specs.git'
target 'MyApp' do
  pod 'MobileFuseSDK'
end

Once you have run pod install you should then be able to include the MobileFuse SDK in your app, using the following import statement:

@import MobileFuseSDK;

Step 2. Configure Data Privacy

The MobileFuse SDK supports privacy configurations that can be managed using an IAB compatible US Privacy String, and IAB Consent Framework strings for GDPR. You can also notify the SDK whether your user subject to COPPA, due to them being under 13 years of age.

The following snippet demonstrates configuration for the US privacy and COPPA compliance:

MobileFusePrivacyPreferences *privacyPreferences = [[MobileFusePrivacyPreferences alloc] init];
[privacyPreferences setSubjectToCoppa:NO]; // Shound be YES if user is under 13 years of age
[privacyPreferences setUsPrivacyConsentString:@"<US Privacy String>"]; // e.g. 1YNN

[MobileFuse setPrivacyPreferences:privacyPreferences];

GDPR for European users

For your European users, you must supply an IAB-compatible privacy consent string. The following example shows how to declare consent for a user which is subject to GDPR due to being located in an EAA country. Note that this should be invoked on the same MobileFusePrivacyPreferences object as above.

MobileFusePrivacyPreferences *privacyPreferences = [[MobileFusePrivacyPreferences alloc] init];
[privacyPreferences setIabConsentString:@"<IAB Consent String>"];

[MobileFuse setPrivacyPreferences:privacyPreferences];

To ensure that you get reliable ad fill and the best CPMs, please ensure that you implement the data privacy methods that are relevant to your user.

App Tracking Transparency Framework

You must also ensure that you have implemented the Apple App Tracking Transparency Framework into your app before any ad calls. This sample code shows how you can request the authorization. If authorization has already been granted, then the callback will immediately fire with the correct status, therefore it’s advisable to call the requestTrackingAuthorizationWithCompletionHandler method every time your app launches.

#import <AppTrackingTransparency/AppTrackingTransparency.h>

// ...

- (void)requestAppTracking {
    [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
        switch (status) {
            case ATTrackingManagerAuthorizationStatusNotDetermined:
                NSLog(@"ATT - Request not determined");
                break;
            case ATTrackingManagerAuthorizationStatusRestricted:
                NSLog(@"ATT - Request restricted");
                break;
            case ATTrackingManagerAuthorizationStatusDenied:
                NSLog(@"ATT - Request denied");
                break;
            case ATTrackingManagerAuthorizationStatusAuthorized:
                NSLog(@"ATT - Request authorized");
                break;
        }
        
        // Run the initialization on our main thread:
        dispatch_async(dispatch_get_main_queue(), ^{
            [self initMobileFuseSdk];
        });
    }];
}

Step 3. Initialize the SDK

To initialize the SDK, you’ll need to provide a valid App ID.

If you don’t have an App ID for the SDK, please ask your MobileFuse contact. You’ll be given a unique App ID for each app and each platform that you publish to.

The following code snippet demonstrates a simple SDK initialization. Passing in the delegate is optional, but it will allow you to handle the onInitSuccess and onInitError callbacks.

// ...

- (void)viewDidLoad {
    [super viewDidLoad];
    [self requestAppTracking]; // Will call initMobileFuseSdk when ATT has been resolved.
}

- (void)initMobileFuseSdk {
    [MobileFuse initWithAppId:@"00000" withPublisherId:@"0000" withDelegate:self];
}

// IMFInitializationCallbackReceiver delegate implementation
- (void)onInitSuccess:(NSString *)appId withPublisherId:(NSString *)publisherId {
    NSLog(@"SDK Initialization successful");
}

- (void)onInitError:(NSString *)message forAppId:(NSString *)appId withPublisherId:(NSString *)publisherId {
    NSLog(@"SDK Initialization failed: %@", message);
}

Step 4. Create Ad Units

Once the SDK has initialized, you can start using MobileFuse ad units. The following guides provide steps to get started with each of our supported ad formats:

Step 5. Configure SKAdNetwork IDs

Recommended - follow the guide below to configure the MobileFuse buyer SKAdNetwork IDs in your app:

Apple SKAdNetwork IDs

Testing your integration

Read our guide on testing your integration:

iOS - Testing integrations

  • No labels