我正在为我的 ios 应用程序使用 Firebase 应用程序内消息服务。消息弹出窗口完美显示。但是,当我单击弹出窗口中的按钮时,即使我在我的应用程序上将以下代码编写为 Firebase 文档,也不会发生任何事情。可通过此处的链接访问文档。
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
}
...
我不想将 Firebase 控制台用于按钮操作或路由,因为该操作将随着应用程序的状态而改变。因此它应该在代码上定义。如果你能帮助我,我会很高兴的!