class MyInAppMessagingDelegate: NSObject, InAppMessagingDelegate {
func messageClicked(_ inAppMessage: InAppMessagingDisplayMessage, campaignInfo: InAppMessagingCampaignInfo?) {
// Check if the message is of type InAppMessagingModalDisplay
guard let modalDisplay = inAppMessage.displayInfo as? InAppMessagingModalDisplay else {
return
}
// Check the button ID to perform specific actions
if inAppMessage.triggerAction.actionButton?.buttonId == "updateButton" {
// Handle Update button click
// Add your custom logic here
} else if inAppMessage.triggerAction.actionButton?.buttonId == "cancelButton" {
// Handle Cancel button click
// Add your custom logic here
}
}
import FirebaseInAppMessaging
class CustomInAppMessagingDisplayDelegate: NSObject, FIRInAppMessagingDisplayDelegate {
func messageClicked(_ inAppMessage: FIRInAppMessagingDisplayMessage, with action: FIRInAppMessagingAction) {
// Handle the click action for the In-App message
}
func messageDismissed(_ inAppMessage: FIRInAppMessagingDisplayMessage, dismissType: FIRInAppMessagingDismissType) {
// Handle the dismiss action for the In-App message
}
func messageWillDisplay(_ inAppMessage: FIRInAppMessagingDisplayMessage) {
// Customize the display of the In-App message
// Access the message components
let title = inAppMessage.messageContent.title.text
let subtitle = inAppMessage.messageContent.body.text
let actionButton1 = inAppMessage.messageContent.actionButton?[0]
let actionButton2 = inAppMessage.messageContent.actionButton?[1]
// Create a custom popup with the message components
// Display the popup with the provided title, subtitle, and buttons
}
func impressionDetected(for inAppMessage: FIRInAppMessagingDisplayMessage) {
// Track impression events for the In-App message
}
}
// Register the custom display delegate
FIRInAppMessaging.inAppMessaging().delegate = CustomInAppMessagingDisplayDelegate()
2条答案
按热度按时间u2nhd7ah1#
这是我的代码:
}
你可以尝试两个按钮(更新和取消)
0md85ypi2#
要自定义应用中消息的显示,您需要实现FIRInAppMessagingDisplayDelegate协议。这允许您为应用内消息提供自定义显示。
以下是如何自定义应用内消息显示的示例:
希望这能帮到你