Gravite Plugin Documentation for iOS

Gravite Plugin Documentation for iOS

 

Gravite Plugin Integration Manual

Important Notice
Starting from Version 10, all libraries are integrated into the Yieldlove Pacakge. Please read carefully in the setup section.
For better resource management, we start to use iOS 15 from this version.

Ensure you are using the correct version for all dependencies.

Release Note (v10.2.1)

  • Disabled Gravite Shake Debug mode by default. This will be enabled when inspection mode is enabled.

Gravite Plugin for iOS

If you wish to use Gravite, please contact your Ströer account manager for assistance.

Note: This feature is only available from Version 9.9.0 onwards.

1. Overview

This manual shows how to set up Gravite in YieldloveAdIntegration in your iOS app.

2. Before you start

Please read https://stroeerdigitalgroup.atlassian.net/wiki/x/FgGyc first. This manual describes only how to enable Gravite Feature.
Additionally, Gravite validates the bundle ID to provide its services. Ensure that your bundle ID is registered with Gravite before proceeding.

3. Try out our example app

  • We will update the example application soon.

4. Adding SDK to your project

4.1. Cocoapods integration

The ad integration package is distributed as a “Pod”. Follow the instructions to install CocoaPods into your app. Afterwards, the SDK dependency can be integrated.

Update repository
pod repo update

Edit your Podfile so that SDK is included as a dependency.

Include SDK pod

YieldloveAdIntegration/Gravite includes only AATKit/Core. So, without AATKit library, the limited ads will be served. Please check https://aatkit.gitbook.io/ios-integration/start/setup/cocoapods to include/exclude adnetworks.

pod 'AATKit', '3.12.3' #Option to speficy the AATKit version. 3.12.0 is the verfied version pod 'YieldloveAdIntegration/Gravite', '10.2.1'

Then run

Install SDK
pod install

Note: Our modules, alongside other dependencies, may require you to use a minimum targeted iOS version 15.0 or higher.

4.2. Swift Package Manager (SPM) integration

Follow the instructions here: https://stroeerdigitalgroup.atlassian.net/wiki/spaces/SDGPUBLIC/pages/1890713878/iOS+integration+documentation#4.2.-Swift-Package-Manager-(SPM)-integration

Add the Core and Gravite product to your Target, as pictured. (YieldloveAdIntegration & YieldloveAdIntegration_Gravite)

Click Add Package.

NOTE: YieldloveAdIntegration_Gravite includes only AATKit-Core. So, without AATKit library, limited ads will be served.Please check https://aatkit.gitbook.io/ios-integration/start/setup/swift-package-manager to include/exclude adnetworks.

5. Implementation

Initialize Gravite

To get started with Gravite, you need to initialize it properly.

// Initialize the GraviteLoader GraviteLoader.shared.initialize() { success in if success { // Initialization succeeded // Add any setup or actions needed after a successful initialization } else { // Initialization failed // Handle the failure, such as logging an error or retrying initialization } }
Enable test mode / debug mode

To test the Gravite feature, the following code should be called.

// Gravite // Enable Gravite debug mode. This will write more log to check GraviteLoader.shared.enableDebugMode() // Enable test mode for Gravite with the specified bundle ID and test account ID GraviteLoader.shared.enableTestMode(bundleId: "bundleID", accountId: testAccountID, forceToExecute: true) // Initialize the GraviteLoader GraviteLoader.shared.initialize() { success in if success { // Initialization succeeded // Add any setup or actions needed after a successful initialization } else { // Initialization failed // Handle the failure, such as logging an error or retrying initialization } }

DebugMode

The Debug Mode provides detailed logs to assist with troubleshooting and debugging

EnableTestMode Method

public func enableTestMode(bundleId: String? = nil, accountId: Int? = nil, forceToExecute: Bool = false)

Parameters:

  • bundleId
    Gravite identifies your app using its bundle ID. If you need to use a different bundle ID for publishing, testing, or other purposes, you can override the default bundle ID by specifying an "alternative bundle ID" here.

    • To use the app’s default bundle ID, pass null.

  • accountId
    AATKit’s test mode allows ad testing even before your app is fully set up with Gravite. Use your accountId to activate test mode.

    • If not needed, pass null.

  • forceToExecute
    If set to true, the SDK will bypass normal ad rendering and always call Gravite Ads. This ensures that your application integrates properly with Gravite.

Important Note

Debug Mode and Test Mode must not be enabled in production environments. These modes are intended only for testing and development.

 

Enable Placements Mapping Table

StroeerSDK features a placement mapping capability that automatically translates Stroeer placement names to their corresponding Gravite placements. This eliminates the need to create identical placement names for each provider, streamlining the integration process.

As Gravite doesn’t use ‘zone’ concept, we send only placement names to Gravite.

  • home_b1 → b1

  • zone_b2 → b2

Make sure that your mapping table is based on the placement name for Gravite.

let mappingTable: [String: String] = [ "b1": "gb1", "b2": "gb2" ] GraviteLoader.shared.setPlacementMapTable(stroeerToGravite: mappingTable)

This configuration ensures that when GraviteLoader processes placements:

  • Stroeer placement b1 will be mapped to Gravite placement gb1.

  • Stroeer placement b2 will be mapped to Gravite placement gb2.

Enable Direct Call mode (Experiment)

StroeerSDK provides to call Gravite directly bypassing the Stroeer Ad request. Please contact to Stroeer dealers to discuss about this feature.
To enable Gravite Direct Call, use the following code:

GraviteLoader.shared.setCacheSize(size: 3) GraviteLoader.shared.enableDirectGraviteCall()

Gravite includes a pre-load feature to display banners and interstitial ads seamlessly. By default, the cache size is set to 1. However, enabling the direct call feature can cause the cache to empty more frequently, leading to delays while new ads are loaded.

To ensure ads are displayed promptly, consider increasing the cache size. If you notice frequent empty ads in your application, adjusting the cache size can significantly improve performance. The maximum allowable cache size is 5, and increasing it can help maintain a steady flow of ads for your users.

 

5.2 Additional implementation

Gravite requires two specific functions to be called when switching between UI pages. This should be implemented in each viewController.
Failure to implement these methods will result in Gravite advertisements not being rendered properly.

class BannerViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) // Always call the superclass implementation first // Notify GraviteLoader that the view has appeared GraviteLoader.shared.viewDidAppear(viewController: self) } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) // Call the superclass implementation last // Notify GraviteLoader that the view is about to disappear GraviteLoader.shared.viewWillDisappear(viewController: self) } }

 

5.3 Targeting

If you want to use contextual targeting with Gravite, refer to the following example. While the standard Android manual allows you to use targeting, note that these settings will not be sent to Gravite. Therefore, when Gravite is enabled, ensure you use this specific targeting method. The targeting configured this way will be applied globally.

// Define sample custom targeting parameters let sampleTargets: [String: String] = [ "userAge": "25", // Example: User's age "userInterest": "sports, technology, music", // Example: User's interests as a comma-separated string "userLocation": "New York" // Example: User's location ] // Apply the custom targeting globally using Yieldlove Yieldlove.instance.setCustomTargets(targets: sampleTargets)