Create in-apps with JavaScript
In-app messages are displayed directly within the app interface while a user is already interacting with an app. As a result, users perceive in-apps as less intrusive than push notifications, emails or SMS.
In-app messages always contain images or videos called Rich Media. In-apps can also include formatted text, links, buttons with CTAs, and other data, allowing you to communicate with your app users in engaging forms.
In-Apps are HTML-based and support JavaScript. Pushwoosh SDK injects pushwoosh
variable that provides the following API:
You can use postEvent
method to send a new event directly from In-App JavaScript code.
You can also use sendTags
method to set tags for the device from an in-app:
To get device tags, use the getTags
method as follows:
If you want to close an in-app from the JavaScript code call closeInApp()
method:
Or simply use custom scheme URL for the button/link <a href="pushwoosh://close">
When sending a push notification with Rich Media, you can get custom data of that push with the following code: pushwoosh.getCustomData()
Custom JavaScript interface
In-App Messages JavaScript functionality can be unlimitedly extended by exposing native Java/Objective-C/Swift methods to JavaScript. This can be achieved with addJavaScriptInterface
methods of Pushwoosh SDK for iOS and Android.