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
One package for websites, React, Angular, and Ionic apps. Identify the customer, start messaging, and your dashboard campaigns appear: 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
- Script tag
- React
- Angular
- Ionic + Capacitor
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.
- Script tag
- React
- Angular
- Ionic + Capacitor
Load the script build before your own scripts. It defines
window.Gameball and needs nothing else.index.html
The script URL is provided when your workspace is enabled for the private beta.
Quick Start
Four calls carry the integration:init once at startup, identify when you know who the visitor is, startInAppMessaging to begin evaluating campaigns, and stopInAppMessaging on logout.
- Script tag
- React
- Angular
- Ionic + Capacitor
1. Configure at page load. 2. Identify, then start. Run this wherever your page learns who the visitor is.3. Send the events your campaigns trigger on.
init configures the API client and nothing else. No network request is made until you identify a customer.index.html
gameball-setup.js
Multi-page sites re-run all of it. Every navigation is a fresh page load, so
init, identify, and startInAppMessaging all run again. That is expected and cheap: the SDK reads its cached sync, and the display history in localStorage means a once-per-customer message still shows only once.Start and Stop
startInAppMessaging syncs your campaigns, evaluates the session-start ones, and begins listening for your events. It needs an identified customer, so call it after identify, or pass customerId directly.
stopInAppMessaging() belongs on logout. It dismisses anything on screen, clears the in-memory session, and flushes analytics. It deliberately keeps the stored display history and the unsent outbox, because dropping them would lose impressions the backend has already counted and would let a once-ever message show again. Identifying a different customer is what discards them.
Single-page apps need no route hooks. Messages are drawn into a Shadow DOM overlay attached to
document.body, outside your framework’s tree, so a re-render or a route change never removes one. You do not restart messaging per route.Control Display and Actions
All hooks are optional and all are passed tostartInAppMessaging. beforeDisplay decides whether a message may appear right now, and onAction lets you handle a button yourself.
Holding Messages Behind Your Own Overlays
While your own modal, drawer, or checkout step is open, tell the SDK so a message does not land on top of it. The held message displays as soon as you clear the flag.Actions
A message’s surface and each of its buttons carry one action.action.type is a string, so a switch covers them.
Observe Messages
Every selected message is published to any listener you register, whatever the SDK then does with it.onInAppMessage returns an unsubscribe function — call it, or you leak the listener.
Events and Purchases
Send the events your campaigns are triggered by. Properties feed the campaign filters, and they are evaluated locally before the request goes out, so a matching message can display immediately.logPurchase is the reserved purchase event, so both any-purchase and price-filtered campaigns match it.
Both calls need an identified customer. Before
identify, sendEvent logs sendEvent ignored: identify a customer first and does nothing.Language
The message locale comes from the customer’spreferredLanguage when they have one, otherwise from init({ lang }), otherwise English. Changing it takes effect at the next session, because the locale is chosen by the sync.
Arabic messages render right-to-left. The overlay reads the resolved locale first and the document’s dir second, so a page that is already RTL needs no extra configuration.
Push Permission
A campaign button can ask for notification permission. On the web the SDK callsNotification.requestPermission(). Inside Capacitor it raises the native prompt through @capacitor/push-notifications, falling back to Notification.requestPermission() when that plugin is not installed.
Supply your own requester if you use a push provider with its own flow. Return true only when permission was actually granted.
The Capacitor Adapter
The adapter is what turns the same package into a native integration. Every plugin is detected at runtime: one you have not installed falls back to the web default with a log line, and theplugins argument is optional when Capacitor’s own registry already holds them. The adapter has no build-time dependency on Capacitor, so a website’s bundle is unaffected.
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 on the web.Logging and Troubleshooting
Passdebug: true to init for a running commentary prefixed [GameballIAM].
API Reference
Launch Checklist
1
Configure once, before anything renders
init runs once at module load or in a script tag above anything that could call the SDK, never inside a component.2
Identify and start
identify runs on login and on every page load for a signed-in visitor, and stopInAppMessaging runs on logout.3
Handle your framework's lifecycle
In React, the effect that starts messaging returns
stopInAppMessaging() from its cleanup. In Angular, every hook that touches the UI is wrapped in NgZone.run(). In Ionic, Capacitor’s App plugin is aliased if your root component is also called App, and no platform is passed to init.4
Wire hooks and overlays
onNavigate is wired to your router, or your campaigns use no navigate actions, and setOverlayOpen brackets your own modals, drawers, and checkout steps.5
Check CSP and release settings
Your Content Security Policy allows the API host and the artwork CDN, campaign artwork is served over
https, and debug is false before release. Test an Ionic build in the native shell rather than ionic serve.Related Articles
In-App Messaging Campaigns
Campaign options, triggers, delivery rules, and analytics definitions.
Initialize Widget
Set up the Gameball widget on your website.
Track Events
Send the events your campaigns are triggered by.
Go-Live Checklist
Verify the full web integration before release.