In-App Notifications
In-app notifications are modal messages displayed while your app is in the foreground. SDK handles them automatically - when a Positive User in-app message arrives, it's presented on top of your current view controller with no extra setup required.
Customize the close button label
The close button reads "Close" by default. Set inAppAlertCloseButtonText before the SDK is initialized to change it globally:
UserSDK.inAppAlertCloseButtonText = "Got it"
UserSDK.default = UserSDK(
application: application,
apiKey: "YOUR_API_KEY",
baseURL: "your-domain.user.com",
shouldTrackActivities: false
)
Use a custom font
If your in-app messages reference a font that isn't a system font, implement FontResolving and assign it to the SDK:
class AppFontResolver: FontResolving {
func resolveFontFor(name: String, size: CGFloat) -> UIFont? {
return UIFont(name: name, size: size)
}
}
UserSDK.default?.fontResolver = AppFontResolver()
The SDK calls resolveFontFor(name:size:) whenever it needs to render text in an in-app message. Return nil to fall back to the system font.
Handle button taps
By default, buttons in in-app messages open their URL in the browser. To intercept that - for example, to handle a deep link inside your app - implement InAppNotificationClickDelegate:
class AppInAppDelegate: InAppNotificationClickDelegate {
func inAppNotificationDidClick(url: URL) -> Bool {
guard url.scheme == "myapp" else {
return false // not your URL - let the SDK open it in the browser
}
// handle deep link navigation
return true // you handled it, SDK won't open the browser
}
}
UserSDK.default?.inAppNotificationClickDelegate = AppInAppDelegate()
Returning true tells SDK you've handled the URL. Returning false lets SDK open it.