Customizing in-app message templates

This guide provide details on customizing capping and Rich Media pages for in-app message templates

This article is aimed mainly at developers.

I ain't afraid of no ghosts!

While Welcome Newcomers and Showcase App Changes are very straightforward and any Rich Media could be used there, Increase Push Opt-In Rate and Recover Opted Out Users are a bit different. Let's take a closer look.

Available only for SDK versions iOS 5.7.1, Android 5.7.2 or later.

1. In-App Message Capping

All business cases have default frequency capping settings. However, for the Increase Push Opt-In Rate and Recover Opted Out Users templates, you can reset capping or change it via the SDK.

Reset capping

To reset capping, call the resetBusinessCasesFrequencyCapping SDK method. It's useful for testing, debug processes, and special occasions when you want to show the out-of-the-box in-app message without any capping.

PWInAppManager.shared().resetBusinessCasesFrequencyCapping()

Customize capping

Both Increase Push Opt-In Rate and Recover Opted Out Users are capped to 1 impression a day by default. To change capping settings, add Pushwoosh_InAppBusinessSolutionsCapping to your AndroidManifest.xml or Info.plist. The value may be any positive integer or decimal fraction. To limit the number of impressions to 1 per X days, use integers. The following example sets in-app message frequency capping to 1 impression in 2 days:

AndroidManifest.xml
<meta-data
           android:name=“com.pushwoosh.in_app_business_solutions_capping”
           android:value=“2” /> 

To show the in-app message several times a day, use decimal fractions. For example, to display the in-app message 4 times a day, set the frequency capping to 0.25. The value will limit displaying of the In-App to once every six hours.

AndroidManifest.xml
<meta-data
           android:name=“com.pushwoosh.in_app_business_solutions_capping”
           android:value=“0.25” />

2. How It's Made?

If Increase Push Opt-In Rate and Recover Opted Out Users In-App templates are enabled in your Control Panel, they are triggered by calling the registerForPushNotifications SDK method:

PushNotificationManager.push().registerForPushNotifications()

When you call this method, Pushwoosh SDK checks for push notification permission.

  • If push notifications are enabled, the SDK doesn't show the in-app message. Thus, we avoid asking users to subscribe for push notifications if they already are subscribed.

  • If push notifications aren't yet enabled, the SDK displays the Increase Push Opt-In Ratein-app message.

  • If push notifications have been explicitly disabled by the user – that's where the Recover Opted Out Users goes into action.

When displayed to the user, Increase Push Opt-In Rate and Recover Opted Out Users rely on the In-App Messaging Javascript to communicate with Pushwoosh SDK.

Increase Push Opt-In Rate

This template contains the following Javascript:

<script type="text/javascript">
var submitButton = document.getElementById('submit');

submitButton.onclick = function(event) {
	event.preventDefault();
	if (window.pushwoosh && window.pushwoosh.registerForPushNotifications) {
		window.pushwoosh.registerForPushNotifications();
	}

	if (window.pushManager && window.pushManager.closeInApp) {
		window.pushManager.closeInApp();
	}
};
</script>

This script adds onclick function to Rich Media submit button. The function calls Pushwoosh In-App Messages API window.pushwoosh.registerForPushNotifications(); to register for push notifications and then closes In-App by calling window.pushManager.closeInApp();

Recover Opted Out Users

Contains the following Javascript:

<script type="text/javascript">
var submitButton = document.getElementById('submit');

submitButton.onclick = function(event) {
	event.preventDefault();
 	if (window.pushwoosh && window.pushwoosh.openAppSettings) {
		window.pushwoosh.openAppSettings();
	}

	if (window.pushManager && window.pushManager.closeInApp) {
		window.pushManager.closeInApp();
	}
};
</script>

This script adds onclick function to the submit button of Rich Media. The function calls Pushwoosh In-App Messages API window.pushwoosh.openAppSettings(); to open native settings screen and then closes In-App by calling window.pushManager.closeInApp();

Now you know the mechanics and the In-App Message scripts to create your own customized Push Subscription/Opt-Out Recovery In-App Messages!

Last updated

#1685:

Change request updated