Skip to content


Customizing in-app message behavior on click

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.

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:

HOW HELPFUL WAS THIS PAGE?
New Stuff!