Most mobile devices do not allow users to select or copy text directly from a push notification. To provide a copyable code, use one of the two methods below.
Use an in-app message
This method works for both iOS and Android. You show the code on an in-app page that opens when the user taps the notification and the app opens.
- Create an HTML page for your in-app message that includes the coupon code and a copy button.
- Add a JavaScript function to the button that uses the Clipboard API:
function copyCode() {
var code = "SAVE20";
navigator.clipboard.writeText(code).then(function() {
alert("Code copied");
});
}
- In your Customer Journey, add a Push element.
- In the Push element, turn on Split flow if message is opened and set how long to wait to check opens. Connect the Opened branch on the canvas. See Push element.
- Connect the Opened branch to an In-App element and select your HTML page. With the default On next app launch mode, the message is shown right away if the app is open; otherwise it is shown the next time the user opens the app. See In-App element.
Use a native action button (Android)
Android allows you to add custom buttons to the notification itself. This method requires a developer to modify the app code. They must use a custom NotificationFactory to add a Copy action button to the notification builder. When the user taps this button, the app runs a background task to put the code into the system clipboard. See Customize Android SDK.
Comments
0 comments
Please sign in to leave a comment.