Docs

Messages

In-app messaging and push notifications with the Grovs iOS SDK

If console messages have automatic display enabled in your dashboard, they will appear in your app without any additional integration.

Push notifications

Follow the steps below to enable push notifications for messages sent from the Grovs dashboard.

1. Add the Push Notifications capability

In Xcode:

  1. Select your app target
  2. Go to Signing & Capabilities
  3. Click + Capability
  4. Search for and add Push Notifications

You also need to add the Background Modes capability and check Remote notifications if you want your app to receive silent or background pushes.

2. Upload your APNs key to Grovs

In your Apple Developer account:

  1. Go to Keys and create a new key with Apple Push Notifications service (APNs) enabled
  2. Download the .p8 key file and note the Key ID and your Team ID

Then in the Grovs dashboard:

  1. Go to your app's Settings → Push Notifications
  2. Upload the .p8 key file
  3. Enter the Key ID and Team ID

3. Request notification permission

Before your app can receive push notifications, you must ask the user for permission. Add this early in your app's lifecycle — for example, in application(_:didFinishLaunchingWithOptions:) or when contextually appropriate:

Swift
import UserNotifications
 
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
    if granted {
        DispatchQueue.main.async {
            UIApplication.shared.registerForRemoteNotifications()
        }
    }
}

Call registerForRemoteNotifications() on the main thread after the user grants permission. This triggers the system to request a device token from APNs.

4. Pass the device token to Grovs

Implement the AppDelegate callback to receive the token and forward it to the SDK:

Swift
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
    Grovs.pushToken = token
}

You can also handle registration failures for debugging purposes:

Swift
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    print("Push registration failed: \(error.localizedDescription)")
}

Push notifications do not work in the iOS Simulator. Test on a physical device.

Displaying messages

Show the full list of messages as a modal:

Swift
Grovs.displayMessagesViewController {
    // Modal was dismissed
}

Unread count

Get the number of unread messages — useful for showing a badge:

Swift
Grovs.numberOfUnreadMessages { count in
    print("Unread: \(count)")
}