Push Notifications

Integrate your app with Gameball push notifications.

Gameball uses Firebase to deliver maximum experience in your app.

Configure Gameball with Your Firebase

Before you start, you must configure your Firebase on your Gameball account. Follow the steps in Configure your Firebase account on Gameball for mobile push notifications article from our Help Center related to push notifications.

Handling Push Notifications Integration

Configure notifications as usual and add two more methods using our SDK. This is normal integration for general firebase notifications configuration, so here is a how-to guide.

1. Add the below to the AppDelegate class

Inherit :UNUserNotificationCenterDelegate, MessagingDelegate
Add var gameballApp: Gameball?

2. Then put these lines didFinishLaunchingWithOptions() in AppDelegate

FirebaseApp.configure()
registerForPushNotifications()

3. Add these stack of lines to the AppDelegate class

    func registerForPushNotifications() {
        UNUserNotificationCenter.current()
            .requestAuthorization(options: [.alert, .sound, .badge]) {
                [weak self] granted, error in
                UNUserNotificationCenter.current().delegate = self
                Messaging.messaging().delegate = self
                guard granted else { return }
                self?.getNotificationSettings()
        }
    }

    func getNotificationSettings() {
        UNUserNotificationCenter.current().getNotificationSettings { settings in
            guard settings.authorizationStatus == .authorized else { return }
            DispatchQueue.main.async {
                UIApplication.shared.registerForRemoteNotifications()
            }
        }
    }

4. Follow this guide on how to access the registration token and pass the acquired device token to Gameball, along with other player attributes, using the registerPlayer function.

Last updated