iOS SwiftUI Example

In SwiftUI you can use FuseAdViewRepresentable wrapper around FuseAdView.

Simple use of FuseAdViewRepresentable

import SwiftUI
import FuseAppSDK

struct MyView: View {

    var body: some View {
        VStack {
            FuseAdViewRepresentable(code: "<zone_code>")
                .padding()
        }
    }
}

Advanced use of FuseAdViewRepresentable

FuseAdViewRepresentable has several extra parameters which can be provided to modify default behaviour:

import SwiftUI
import FuseAppSDK

struct MyView: View {

    var body: some View {
        VStack {
            FuseAdViewRepresentable(
                code: "<zone_code>",
                loadingBehaviour: .progressBar,
                errorBehaviour: .hide,
                params: FuseAdViewParams(customTargeting: ["pos": "1"])
            )
                .padding()
        }
    }
}

Dynamic Updates

Sometimes you may need to set change the zone code dynamically (after the page first rendered). In this case, you should add an identifier to FuseAdViewRepresentable to ensure it gets re-rendered each time the zone code changes:

import SwiftUI
import FuseAppSDK

struct MyView: View {
    @State var zoneCode = "<zone_code>"

    var body: some View {
        VStack {
            ...

            FuseAdViewRepresentable(code: zoneCode)
                .id(zoneCode)
        }
    }
}