Skip to main content
Private beta. In-App Messaging is not yet generally available. To enable it for your workspace, contact your account manager or email support@gameball.co.

Display In-App Messages

Add one call after you identify the customer and the Gameball SDK shows your dashboard campaigns inside the app: slide-ups, modals, and full screens, triggered by session start or by the events you already send. For campaign options, triggers, filters, priority, cooldown, quiet hours, and how the analytics are defined, see In-App Messaging Campaigns.

Requirements

No extra dependencies are added for in-app messaging. The SDK already ships firebase_messaging, url_launcher, and shared_preferences, which is what the module uses.

Install

Private beta build. The SDK is not published to the public package registries, so the version below is a placeholder. To get the build and its version, contact your account manager or email support@gameball.co.
pubspec.yaml
Initialize the SDK as you do today, then identify the customer. Both must happen before messaging starts, because the sync needs the API key and the customer ID.

Start Messaging

Give your MaterialApp a navigator key and pass the same key to startInAppMessaging. Call it as soon as the customer is known; it is safe to call before the first frame.
To stop, call stopInAppMessaging(). It dismisses anything on screen, flushes pending analytics, and clears the module’s state. Check isInAppMessagingStarted if you need to know whether it is running. App lifecycle is observed automatically.

Control Display and Actions

beforeDisplay

The hook is synchronous. If it throws, the SDK logs and shows the message.

onAction

Called for every tap with the message, the button (or null for the surface), and the parsed action. Return true to take over, or false for built-in handling. In both cases the click is reported and the message is dismissed before the action runs, so a navigation transition is never covered by the overlay.

onNavigate

When supplied, every navigate action is handed to you with its route name and optional arguments map. When absent, the SDK calls Navigator.pushNamed on your navigator. A route that is not registered is logged, never thrown.

Actions

GameballClickAction is a sealed class, so an exhaustive switch is safe.

Observe Messages

onInAppMessage is a broadcast stream of every message the SDK selects, emitted before beforeDisplay is consulted. It is observation only, and subscribing does not affect analytics. Subscribe any time, including before startInAppMessaging.
GameballInAppMessage exposes id, type, header, body, imageUrl, iconUrl, buttons, clickAction, extras, style, layout, orientation, slidePosition, showCloseButton, dismissOnScrimTap, and autoDismissAfter.

Events and Purchases

Campaigns trigger on the events you already send with sendEvent. The event name is matched case-insensitively, and the event’s properties are what the campaign’s filters read, so send numbers as numbers where a filter compares them. logPurchase reaches campaigns as the reserved event purchase, with productId, price, currency, and quantity as properties:

Language

There is no separate language setting for messages. Each sync asks for the customer’s preferredLanguage when your app set one, and otherwise the lang given at init. The value is read at sync time, so a language change takes effect at the next session. Right-to-left languages mirror the layout automatically from the app’s Directionality.

Push Permission

The request push permission button action calls FirebaseMessaging.instance.requestPermission() and treats authorized and provisional as granted. It needs Firebase initialized in your app; if it is not, the SDK logs could not request push permission and the message still closes.
To use your own permission flow, handle the action in onAction and return true.

Behavior Reference

These rules are shared with every Gameball SDK and are described in full in In-App Messaging Campaigns. This is what they mean in a Flutter app.

Logging and Troubleshooting

Every decision is logged with a reason and the campaign ID, prefixed [GameballIAM], through debugPrint. Filter your flutter run or flutter logs output on that prefix. There is no switch; the log is always on.
Nothing shows at all? Check in order: the API key is set and the customer is initialized, the navigator key is the one on MaterialApp, the campaign is live and the customer is in its audience and platform, the sync log lists it, the account cooldown or quiet hours are not suppressing it, and the campaign has not already been shown to this customer. A fresh customer ID is the quickest way to reset frequency history while testing.

API Reference


Launch Checklist

1

Initialize and identify

init with the production API key, then initializeCustomer with a preferredLanguage.
2

Wire the navigator key

The navigatorKey passed to startInAppMessaging is the one on MaterialApp.
3

Register your routes

Every route name your campaigns use is registered, or onNavigate routes it.
4

Initialize Firebase if needed

Firebase is initialized if any campaign asks for push permission.
5

Test end to end

Events carry numeric properties as numbers where campaigns filter on them. Run one campaign on a fresh customer ID and watch the [GameballIAM] log.

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 Flutter integration before release.