Installing with Objective-C

Step 1: Installing Using Obj-C

  1. Download the latest version of the Fyber SDK. Feel free to check the changelog.

  2. Drag the fyber-sdk-lib folder from a Finder window to your project’s Xcode window. You'll find this folder in the previously downloaded zip.

Xcode displays a popup, prompting for more details about what to do with the dropped folder.

Make sure that Create groups is checked together with your application's target in the Add to targets section:

Manually Installing

Note

Make sure the static library is listed in the Link Binary with Libraries section of your target’s Build Phases.

Xcode 5 build with modules is enabled by default.

You can check this in the project Build Settings Panel. Search for “Module” and verify if Enable Modules (C and Objective-C) is set to Yes.

Based on that, select one of the following options:

Step 2: Adding User Consent 

GDPR

The General Data Protection Regulation requires you to scope your user's consent. A user is within the GDPR scope for your app when one or all of the following apply:

  • The user is currently located in the EU
  • The user has registered with the app as an EU resident
  • The app is specifically targeted to EU users

Once you have collected the user’s consent, you can pass them onto the SDK using the following API:

Objective-C
BOOL userConsent = ...;
[[FyberSDK instance].user setGDPRConsent:userConsent];

userConsent should be Yes if you have the user’s consent, or No otherwise.

We recommend that the first time you gather the user’s consent, you pass it onto the SDK before starting the SDK. The SDK will then take the user’s consent into consideration when initializing. In the following sessions, you will only need to call the API if the user updates his or her consent.

More information on GDPR can be found under the GDPR Resource Page and FAQs.

CCPA - Privacy String

The intention of the California Consumer Privacy Act of 2018 (CCPA) is to protect the personal information of California residents. CCPA applies to all companies doing business in California. If a California resident uses an app developer’s mobile app, CCPA applies to the developer and every company that processes the personal information of the app’s users.
CCPA came into effect on 1 January 2020.

Setting the IAB US Privacy String

We recommend that the first time you gather a user opt-out (aka 'consent'), you pass it onto the SDK before initializing it. The SDK takes the user opt-out into consideration when initializing.

Once you have collected the user’s opt-out, you can pass it onto the SDK using the following API:

To set the IAB US privacy string, use the following API:

Objective-C
[[FyberSDK instance].user setIABUSPrivacyString:@"1YNN"];
Clearing Privacy Opt-Out

To clear the user opt-out setting, use the following API:

Objective-C
[[FyberSDK instance].user clearIABUSPrivacyString]; 

Step 3: Starting the SDK

Start the Fyber SDK before being able to use any Fyber product.

Warning

You must initialize the SDK on app start for accurate DAU calculations.

To do this, determine a point in your application’s code that is run once. A good example point is the application:didFinishLaunchingWithOptions: method in your application delegate.

Import the Fyber SDK header:

Objective-C
#import "FyberSDK.h"

Now start the SDK!

Objective-C
FYBSDKOptions *options = [FYBSDKOptions optionsWithAppId:@"00000"
                          userId:@"userId"
                          securityToken:@"000000000000000000000000"];
[FyberSDK startWithOptions:options];

The Security Token and appId are required, and can be found in the Settings of your app in the Dashboard. The User ID should uniquely identify the user of your app.

Objective-C
[FyberSDK instance].userId

Note

Check that the userID is not hardcoded and is completely unique for each user.

An Alternate Option

The previous method is our preferred method of starting the SDK.

If you do not want to set a userId yourself and prefer that the Fyber SDK creates it for you, the Fyber SDK can do so when you include the following in your code:

Objective-C
FYBSDKOptions *options = [FYBSDKOptions optionsWithAppId:@"00000"
                                           securityToken:@"000000000000000000000000"];
[FyberSDK startWithOptions:options];

This generates the required unique userId on the first launch of the application and stores it for subsequent launches.

Subsequent usage of the Fyber SDK during your application's lifecycle reuses the parameters passed to this call. If the user re-installs the app, a new userId is generated.

Note

Using optionsWithAppId:securityToken is not Fyber's preferred method to start the SDK, especially if you are planning to user server-side callbacks to handle the user rewarding.

Installing with Cocoapods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like FyberSDK in your projects.

See the CocoaPods Getting Started and Using CocoaPods for more information.

Add the following pod:

Podfile
pod 'FyberSDK', '~> 9.1.1'

Now you may start the SDK, refer to either Objective-C or Swift instructions