Beta. In-App Messaging is in beta and open to every Gameball account. Send questions and feedback to support@gameball.co.
Display In-App Messages
One call after you identify the customer, and the Gameball SDK draws your dashboard campaigns above your app in its own window: slide-ups, modals, and full screens, triggered by session start or by the events you already send. In-app messaging needs Gameball iOS SDK 4.0.0 or later. The module is dormant until you start it: it makes no requests, schedules no timers, stores nothing, and draws nothing. For campaign options, triggers, filters, priority, cooldown, quiet hours, and how the analytics are defined, see In-App Messaging Campaigns.Requirements
Install
Package.swift
https://github.com/gameballers/gameball-ios.git, and select version 4.0.0 or later.
Initialize the SDK and identify the customer as you do today:
Start Messaging
CallstartInAppMessaging() once. It uses the customer already identified with the SDK. Call it before initializeCustomer and the module starts as soon as a customer is identified, or pass an ID explicitly.
initializeCustomer switches messaging to that customer. App lifecycle is observed automatically.
startInAppMessaging() without an ID uses the customer identified in the current app session, which the SDK keeps in memory only, so call initializeCustomer on every launch or pass the ID. isInAppMessagingStarted stays false until a customer is identified.
Call stopInAppMessaging() on logout; it is safe when messaging was never started. Messaging stays off until you call startInAppMessaging() again, so call it at the next login. The customer’s display history stays on the device until a different customer starts, so a campaign already shown to this customer does not return when they log back in.
Control Display and Actions
Assign aGameballInAppMessagingDelegate to inAppMessagingDelegate, before or after starting. Every method has a default, so implement only what you need.
Each hook is called on the main thread. When no delegate is set, or it has been deallocated, the SDK uses the defaults above.
Actions
GameballClickAction is an enum, so an exhaustive switch is safe. The SDK closes the message for dismiss and requestPushPermission. After openURL and navigate, the message stays on screen until the customer closes it, and there is no API to close it from your code.
A button whose action is missing or unusable, such as
openURL without a URL, falls back to .dismiss.
Events and Purchases
Events you already send drive the triggers, and there is nothing extra to call. Triggers are evaluated on the device as soon as you callsendEvent, without waiting for the network. Event names match triggers case-insensitively. Every filter on a campaign must pass, and a filter on a property your event does not carry fails, so send numbers as numbers where a filter compares them.
logPurchase. It sends an event named purchase to Gameball through sendEvent, with productId, price, currency, and quantity in its metadata, so the purchase is recorded whether or not in-app messaging has started. While messaging runs, the same event reaches campaigns, which can filter on those fields. Use it instead of a hand-built purchase event, not alongside one.
logPurchase throws GameballError.emptyCustomerId when customerId is empty, and sends nothing. A key in properties named productId, price, currency, or quantity replaces that field. sessionToken works as it does in sendEvent.
Language
There is no separate language setting for messages. Each sync asks for campaigns in the customer’s preferred language, set throughinitializeCustomer or setLanguage(_:), and otherwise the lang given at init. A code outside the SDK’s supported languages resolves to en. The language is resolved at every sync, so a change applies from the next session.
Messages mirror for right-to-left languages through directional constraints, following your app’s layout direction. The SDK never touches UIView.appearance().
Personalization
Campaign text can contain placeholders such as{player_name} in the header, body, and button labels. See In-App Messaging Campaigns for the list. Right before a message displays, the SDK fetches the customer’s current values, waiting at most 2 seconds. If the request fails or times out, it uses the last values it holds for the customer, then removes any placeholder still without a value, so the customer never sees raw braces. The message still shows.
The message passed to gameballDidSelectMessage and gameballShouldDisplay still contains the raw placeholders. gameballDidHandleAction receives the personalized text.
Push Permission
The request push permission button action callsUNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]), logs the outcome, and closes the message. The click is reported the same way whether the customer allows or declines.
SwiftUI and UIKit
The module needs no view hierarchy from you. It attaches its window to the foregroundUIWindowScene, so it works the same in a SwiftUI App and in a UIKit app with a scene delegate. Keep the delegate object alive for as long as you want the hooks, for example as a property of your app model.
Behavior Reference
The campaign rules themselves are described in In-App Messaging Campaigns. This is what they mean in an iOS app.Logging and Troubleshooting
The module explains its decisions in the console with a[GameballIAM] prefix and never posts these lines to the backend. Logging is on in Debug builds and off in Release builds. To turn it on in a Release build while you reproduce a problem, set:
Nothing shows at all? Check in order:
init ran with the API key and a customer is identified, startInAppMessaging was called, the campaign is live and targets iOS and the customer is in its audience, no skipped or suppressed line names it, and the campaign has not already been shown to this customer. Once per customer is the default. A fresh customer ID resets frequency history while testing. In a Release build, set GameballInAppMessagingLogging = true first.UI Testing
Messages carry stable accessibility identifiers, so your XCUITests do not depend on campaign copy, which can change from the dashboard at any time. VoiceOver still reads the campaign’s own text.API Reference
Launch Checklist
1
Update the SDK and deployment target
The
gameball-ios package at 4.0.0 or later, and your app target’s minimum deployment at iOS 15.0.2
Initialize and identify
init with the production API key, then initializeCustomer with a preferredLanguage on every launch.3
Start and stop messaging
startInAppMessaging() once the customer is known, and stopInAppMessaging() on logout.4
Keep a delegate alive
A delegate object retained by your app, with
gameballShouldNavigate wired if any campaign uses navigate.5
Check events and purchases
Events carry numeric properties as numbers where campaigns filter on them, and purchases go through
logPurchase instead of a hand-built event.6
Test end to end
Run one campaign on a fresh customer ID in a Debug build, or with
GameballInAppMessagingLogging = true, with the Xcode console filtered on [GameballIAM].Related Articles
In-App Messaging Campaigns
Campaign options, triggers, delivery rules, and analytics definitions.
Track Events
Send the events your campaigns are triggered by.
Push Notifications
Reach customers when the app is closed.
Go-Live Checklist
Verify the full iOS integration before release.