Push Notifications

We highly recommend enabling Lucra's Push Notifications in your app to provide a better experience for the end user.

Prerequisites

The Lucra SDK cannot receive push notifications on its own as it isn't a standalone app. So, before starting, please make sure that your app already has push notifications enabled and working. If you need assistance with that, please refer to:

Creating APNS Tokenarrow-up-right

Setting Up Xcode For Pusharrow-up-right With the APNs token information in hand, please contact our team via Slack or email so we can direct Lucra Push Notifications to your app. The following values are needed:

  • Authentication Key (P8 File)

  • Key ID

  • Bundle Identifier

  • Team Identifier

Registering for Push Notifications

Once you've submitted your APNs information to our team, the next step is to pass the user's device token to your LucraClient instance. Use the code snippet below as a reference:

class AppDelegate: NSObject, UIApplicationDelegate {
    static let lucraClient = LucraClient() // fill in the initializer with your own parameters
    
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        AppDelegate.lucraClient.registerForPushNotifications(deviceToken: deviceToken)
    }
}

Handling Push Notifications

The final step is to set up the notification handler. Whenever your app receives a push notification, pass it to our handler. If it’s from Lucra, it will return a LucraFlow to be displayed. Otherwise, it returns nil, and you can handle it as you usually would.

Last updated