B Bubbl Docs

iOS SDK Usage Examples

Start only after FCM token

import FirebaseMessaging
import Bubbl

final class StartGate {
  static let shared = StartGate()

  private var fcmToken: String?

  func setFCMToken(_ token: String) {
    fcmToken = token
    BubblPlugin.updateFCMToken(token)
  }

  func startIfReady(apiKey: String, env: Config.Environment) {
    guard let _ = fcmToken else { return }

    BubblPlugin.shared.start(
      apiKey: apiKey,
      env: env,
      segmentations: [],
      delegate: nil
    )
  }
}

Force refresh geofence

BubblPlugin.shared.refetchGeofence()

If your SDK build exposes coordinate-specific refresh, call that selector from your bridge; otherwise fallback to refetchGeofence().

Push segmentation tags

BubblPlugin.shared.updateSegments(segmentations: ["vip", "beta"]) { result in
  switch result {
  case .success(let ok):
    print("segments updated", ok)
  case .failure(let error):
    print("segment update failed", error)
  }
}

Fetch configuration and privacy text

BubblPlugin.shared.fetchConfiguration(forceRefresh: true) { result in
  switch result {
  case .success(let config):
    print(config.privacyText)
  case .failure(let error):
    print(error)
  }
}

let cachedText = BubblPlugin.shared.getPrivacyText()

Track notification/survey events

BubblPlugin.shared.trackSurveyEvent(
  notificationId: "123",
  locationId: "456",
  activity: "notification_delivered"
) { _ in }

let answers = [
  SurveyAnswer(questionId: 1, type: "RATING", value: "5"),
  SurveyAnswer(questionId: 2, type: "MULTIPLE_CHOICE", value: "YES", choice: [ChoiceSelection(choiceId: 10)])
]

BubblPlugin.shared.submitSurveyResponse(
  notificationId: "123",
  locationId: "456",
  answers: answers
) { _ in }

Observe auth status in UI

.onReceive(BubblPlugin.locationAuthorizationPublisher) { status in
  print("location status", status)
}
.onReceive(BubblPlugin.pushAuthorizationPublisher) { status in
  print("push status", status)
}