Integrating Uptick Digital Advertising Widget into Your Swift iOS Application

Enhance your Swift iOS app by seamlessly integrating our advertising widget. The setup is quick and consists of a few core steps. By following this guide, you can embed the widget and showcase targeted advertising to your audience.

Step 1: Installing Uptick SDK

Swift Package Manager (SPM)

  1. Open your project in Xcode.
  2. In the project navigator, select your project file.
  3. In the project editor, select your app’s target under PROJECT.
  4. Go to the Package Dependencies tab.
  5. Click the + button at the bottom of the Package Dependencies section.
  6. In the search bar, paste the Uptick SDK GitHub repository URL: https://github.com/uptick-ads/uptick-ios
  7. Select the main branch and press Add Package.
  8. Assign the package to your app target.

Step 2: Setting Up the UptickAdView

Programmatic Example:

import UIKit
import UptickSDK

class ViewController: UIViewController {
    // Create a variable for the uptickAdView
    lazy var uptickAdView = UptickAdView()

    override func viewDidLoad() {
        super.viewDidLoad()

        // Add the uptickAdView to your main view
        view.addSubview(uptickAdView)

        // When you want to show the offer flow
        UptickManager.shared.activateAd(
            in: uptickAdView,
            withID: "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE",
            parameters: ["placement": "sdk_order_confirmation"]
        )
    }
}

Troubleshooting Tips

  • Layout Issues: If you encounter any layout disruptions, confirm that you’ve correctly placed the UptickAdView and used the appropriate integration ID.
  • Support: If issues persist, reach out to our technical support team for further assistance.

Customizing the Uptick SDK

There are some events and properties you can access to customize the SDK to better fit your application.

onDissapearView

There is a public closure that occurs when the offers are closed or completed. In any event where they dissapear from the screen. You can subscribe to this and have the possibility to update your layout.

import UIKit
import UptickSDK

class ViewController: UIViewController {
    func setProperties() {
        UptickManager.shared.onDisappearOffer = {
            self.showButton.isHidden = false
            self.defaultButton.isHidden = false
            self.backgroundView.isHidden = true
            self.uptickAdView.removeFromSuperview()
        }
    }
}

onReceivedOffer

We have a public closure that occurs when the offer is received. This may be used to inspect the size of the offer’s frame and dynamically size anything that you need too.

import UIKit
import UptickSDK

class ViewController: UIViewController {
    func setProperties() {
        UptickManager.shared.onReceivedOffer = { offer in
            print("Received Offer: \(offer.frame.width)x\(offer.frame.height)")

            if (offer.isLast) {
                offer.rejectButton.isHidden = true
            }
        }
    }
}

The offer received is a type UptickData.Offer and has these properties

public enum UptickData {
    public class Offer : NSObject {
        // Returns the ID of the offer
        public let id: String

        // Returns the position of the offer
        public let position: Int?

        // Returns the total offers in the flow
        public let total: Int?

        // Returns the frame of the offer view
        public let frame: CGRect

        // Returns the reject button
        public let rejectButton: UIButton
    }
}