AppboyKit (also known as the Objective-C SDK) is no longer supported and has been replaced by the Swift SDK. It will no longer receive new features, bug fixes, security updates, or technical support—however, messaging and analytics will continue to function as normal. To learn more, see Introducing the New Braze Swift SDK.
Customizing in-app message behavior on click
This article includes information on News Feed, which is being deprecated. Braze recommends that customers who use our News Feed tool move over to our Content Cards messaging channel—it’s more flexible, customizable, and reliable. Check out the migration guide for more.
The inAppMessageClickActionType
property on the ABKInAppMessage
defines the action behavior after the in-app message is clicked. This property is read-only. If you want to change the in-app message’s click behavior, you can call the following method on ABKInAppMessage
:
1
[inAppMessage setInAppMessageClickAction:clickActionType withURI:uri];
1
inAppMessage.setInAppMessageClickAction(clickActionType: clickActionType, withURI: uri)
The inAppMessageClickActionType
can be set to one of the following values:
ABKInAppMessageClickActionType |
On-Click Behavior |
---|---|
ABKInAppMessageDisplayNewsFeed |
The News Feed will be displayed when the message is clicked, and the message will be dismissed. Note that the uri parameter will be ignored, and the uri property on the ABKInAppMessage will be set to nil. |
ABKInAppMessageRedirectToURI |
The given URI will be displayed when the message is clicked, and the message will be dismissed. Note that the uri parameter cannot be nil. |
ABKInAppMessageNoneClickAction |
The message will be dismissed when clicked. Note that the uri parameter will be ignored, and the uri property on the ABKInAppMessage will be set to nil. |
For in-app messages containing buttons, the message clickAction
will also be included in the final payload if the click action is added prior to adding the button text.
Customizing in-app message body clicks
The following ABKInAppMessageUIDelegate
delegate method is called when an in-app message is clicked:
1
- (BOOL) onInAppMessageClicked:(ABKInAppMessage *)inAppMessage;
1
func onInAppMessageClicked(inAppMessage: ABKInAppMessage!) -> Bool
Customizing in-app message button clicks
For clicks on in-app message buttons and HTML in-app message buttons (such as links), ABKInAppMessageUIDelegate
includes the following delegate methods:
1
2
3
4
5
6
- (BOOL)onInAppMessageButtonClicked:(ABKInAppMessageImmersive *)inAppMessage
button:(ABKInAppMessageButton *)button;
- (BOOL)onInAppMessageHTMLButtonClicked:(ABKInAppMessageHTML *)inAppMessage
clickedURL:(nullable NSURL *)clickedURL
buttonID:(NSString *)buttonID;
1
2
3
4
5
func onInAppMessageButtonClicked(inAppMessage: ABKInAppMessageImmersive!,
button: ABKInAppMessageButton) -> Bool
func onInAppMessageHTMLButtonClicked(inAppMessage: ABKInAppMessageHTML!,
clickedURL: URL, buttonID: String) -> Bool
Each method returns a BOOL
value to indicate if Braze should continue to execute the click action.
To access the click action type of a button in a delegate method, you can use the following code:
1
2
3
4
5
6
7
if ([inAppMessage isKindOfClass:[ABKInAppMessageImmersive class]]) {
ABKInAppMessageImmersive *immersiveIAM = (ABKInAppMessageImmersive *)inAppMessage;
NSArray<ABKInAppMessageButton *> *buttons = immersiveIAM.buttons;
for (ABKInAppMessageButton *button in buttons) {
// Button action type is accessible via button.buttonClickActionType
}
}
1
2
3
4
5
6
if inAppMessage is ABKInAppMessageImmersive {
let immersiveIAM = inAppMessage as! ABKInAppMessageImmersive;
for button in inAppMessage.buttons as! [ABKInAppMessageButton]{
// Button action type is accessible via button.buttonClickActionType
}
}
When an in-app message has buttons, the only click actions that will be executed are those on the ABKInAppMessageButton
model. The in-app message body will not be clickable even though the ABKInAppMessage
model will have the default click action (“News Feed”) assigned.
Method declarations
For additional information, see the following header files: