Add and initialize the OpenWeb iOS SDK

To add a Conversation to your app, you must import the OpenWeb iOS SDK and then configure your project.



🚧

IMPORTANT

Starting with SpotIMCore 1.1.0, Google-Mobile-Ads-SDK is no longer included as a direct dependency. This change eliminates conflicts that occur when the Google-Mobile-Ads-SDK dependency is also a dependency of the host app.

If you previously integrated with an older version of the OpenWeb iOS SDK, you must make the following changes to upgrade to SpotIMCore 1.1.0 and support ads:

Explicitly add the Google-Mobile-Ads-SDK dependency.
Set Google skadnetworkidentifier
Add GoogleAdsProvider.swift to your project.
Set GoogleAdsProvider following SpotIm initialization


Add the SDK

Using Cocoapods

  1. In a text editor, open Podfile.
  2. Add pod 'SpotIMCore', '1.6.9
  3. Add pod 'Google-Mobile-Ads-SDK', '8.0'
target 'OpenWeb-SDK-iOS-Demo' do
  use_frameworks!

  # Pods for OpenWeb-SDK-iOS-Demo
  pod 'SpotIMCore', '1.6.9'
  pod 'Google-Mobile-Ads-SDK', '8.0'
end
  1. In Terminal at the terminal prompt of your project directory, execute pod install to install the dependencies added to Podfile.
  2. Open the .xcworkspace file for your project to launch Xcode.

Using Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Once you have your Swift package set up, adding SpotIM as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/SpotIM/spotim-ios-sdk-pod.git", .upToNextMajor(from: "1.6.8"))
]


Set Google ads SKAdNetworkIdentifier

  1. In the app Info.plist, add a GADApplicationIdentifier key with your Ad Manager app ID set as the string value, and add a SKAdNetworkItems key with cstr6suwn9.skadnetwork set as the value.
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-***************~**********</string>
<key>SKAdNetworkItems</key>
  <array>
    <dict>
      <key>SKAdNetworkIdentifier</key>
      <string>cstr6suwn9.skadnetwork</string>
    </dict>
  </array>

📘

TIP

If your app cannot hold a GADApplicationIdentifier key, set a GADIsAdManagerApp key.

<key>GADIsAdManagerApp</key>
    <true/>
<key>SKAdNetworkItems</key>
  <array>
    <dict>
      <key>SKAdNetworkIdentifier</key>
      <string>cstr6suwn9.skadnetwork</string>
    </dict>
  </array>


Add GoogleAdsProvider.swift to your project

  1. In the Pod project, verify that GoogleAdsProvider.swift exists in the Pods/SpotIMCore/Resources folder.

    If you cannot find this file, make sure that the dependencies have been added to Podfile and installed.

  1. Copy Pods/SpotIMCore/Resources/GoogleAdsProvider.swift to your app target. If your app uses Google-Mobile-Ads-SDK version 7.69.0 and below, copy Pods/SpotIMCore/Resources/GoogleAdsV7Provider.swift to your app target.


Initialize the SDK with ads

  1. In Xcode, open AppDelegate.swift.
  2. Import the OpenWeb iOS SDK: import SpotImCore
  3. Initialize the SDK in application(application:didFinishLaunchingWithOptions). Be sure to replace SPOT_ID with your Spot ID.
  4. Call SpotIm.setGoogleAdsProvider immediately after SpotIm.initialize(spotId: spotId). Be sure that you have added GoogleAdsProvider.swift to your project.

import SpotImCore

func application(_ application: UIApplication, 
                                didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]?) -> Bool { 
    SpotIm.initialize(spotId: "SPOT_ID")
    SpotIm.setGoogleAdsProvider(googleAdsProvider: GoogleAdsProvider())
    return true
}


Did this page help you?