2

I'm using Firebase In-App Messaging service for my ios app. The message pop-up is shown perfectly. But when I click the button which is on the pop-up, nothing is happen even I write the below codes as Firebase Documentation on my app. Documentation is reachable with this link here.

import FirebaseInAppMessaging
import FirebaseAnalytics

class CardActionFiamDelegate : NSObject, InAppMessagingDisplayDelegate {
    
    func messageClicked(_ inAppMessage: InAppMessagingDisplayMessage) {
        // ...
        print("Message Clicked!")
        
    }
    
    func messageDismissed(_ inAppMessage: InAppMessagingDisplayMessage,
                          dismissType: FIRInAppMessagingDismissType) {
        // ...
        print("Message Dismissed!")
    }
    
    func impressionDetected(for inAppMessage: InAppMessagingDisplayMessage) {
        // ...
        print("Impression Detected")
    }
    
    func displayError(for inAppMessage: InAppMessagingDisplayMessage, error: Error) {
        // ...
        print("Display Error")
    }

}
import UIKit
import Firebase
import FirebaseInAppMessaging

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()
        
        // [START fiam_register_delegate]
        // Register the delegate with the InAppMessaging instance
        let myFiamDelegate = CardActionFiamDelegate()
        InAppMessaging.inAppMessaging().delegate = myFiamDelegate;
        // [END fiam_register_delegate]
        ...
        return true
    }
    ...

I don't want to use Firebase Console for button action or routing because the action will change as state of the app. Therefore it should be define on the code. If you can help me, I'm gonna bee sooo glad!

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
Ilayda şahin
  • 21
  • 1
  • 1

1 Answers1

1

I think .delegate is a weak pointer.

So, define the delegate as a class property. It works for me.