Push notifications
Flyy sends notifications through Firebase Cloud Messaging on both platforms. Push is optional — skip this page if you don't use it.
Push carries three things:
- Notifications — reward won, new offer, reminders. Shown in the tray and/or as an in-app popup.
- Popups — reward and scratch-card popups over your app.
- Silent config refreshes —
flyy_type: config_refresh, sent when GameStudio publishes, so placement changes reach running apps.
- Android
- iOS
Option A — Flyy is your only push source
<service android:name="com.theflyy.sdk.push.FlyyMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Option B — you already have a messaging service
class MyMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
Flyy.syncPushToken(token)
}
override fun onMessageReceived(message: RemoteMessage) {
if (Flyy.handlePush(message.data)) return // Flyy's message — handled
// …your own notifications
}
}
handlePush returns true for Flyy notifications, config refreshes and any other
Flyy message type, and false for yours.
Good to know
- Android 13+: your app must request
POST_NOTIFICATIONS. Without it the tray copy is dropped; in-app popups still show while the app is open. - Icon: set FCM's
com.google.firebase.messaging.default_notification_iconmeta-data. The SDK uses it too. - Background taps: a notification the system drew while the app was in the background is still handled when tapped — the click is reported and the deep link opens. No code needed.
- Token timing: a token synced before init is held and sent at init. Identify and login re-fetch the token, so older installs register too.
Add Firebase Messaging to your app and set up APNs in the Firebase console as usual. Then:
// MessagingDelegate
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
if let fcmToken { Flyy.syncPushToken(fcmToken) }
}
// Silent and data-only pushes (config refresh)
func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completion: @escaping (UIBackgroundFetchResult) -> Void) {
completion(Flyy.handlePush(userInfo) ? .newData : .noData)
}
// UNUserNotificationCenterDelegate
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completion: @escaping (UNNotificationPresentationOptions) -> Void) {
FlyyNotifications.handleForeground(notification.request.content.userInfo)
completion([])
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completion: @escaping () -> Void) {
if let root = window?.rootViewController {
FlyyNotifications.handleTap(response.notification.request.content.userInfo, presenter: root)
}
completion()
}
:::danger Use the FCM token, not the APNs token
Pass the FCM registration token from MessagingDelegate. The hex APNs device
token from didRegisterForRemoteNotificationsWithDeviceToken doesn't work — FCM
rejects it with 404 UNREGISTERED.
:::
When FirebaseMessaging is linked, the SDK also reads Messaging.messaging().fcmToken
itself at init and on each foreground.
Config-refresh topic
When Firebase is present, the SDK subscribes the install to flyy_cfg_<partnerId>
(flyy_cfg_stage_<partnerId> on stage). One push to that topic refreshes every
install after a GameStudio publish. To opt out, set subscribeConfigTopic = false.
Without Firebase, changes arrive on the next foreground.