简体   繁体   English

Kotlin:订阅Firebase云消息(FCM)专题

[英]Kotlin: Subscribe to Firebase Cloud Messaging(FCM) Topic

I've used the Android (Java) way of doing things before for subscribing to a topic我以前使用 Android (Java) 的方式订阅主题

FirebaseMessaging.getInstance().subscribeToTopic("weather")...

But was looking at the Kotlin example但是正在看 Kotlin 的例子

Firebase.messaging.subscribeToTopic("weather")...

I'm not finding how to get this class to show to be able to write it like the above.我找不到如何让这个 class 显示能够像上面那样写。

I can get the Java way to show but not the Kotlin.我可以得到 Java 的显示方式,但不能得到 Kotlin。

Anyone know what needs to be added to the Gradle or other to do this?任何人都知道需要向 Gradle 或其他人添加什么才能做到这一点?

Thanks谢谢

My guess it that you forgot to add the Kotlin extensions, which means you only get the Java-level APIs.我猜你忘记添加 Kotlin 扩展,这意味着你只能获得 Java 级别的 API。

To make the Kotlin extensions available, add the -ktx dependency to your Gradle file as shown in the documentation on setting up Kotlin .要使 Kotlin 扩展可用,请将-ktx依赖项添加到您的 Gradle 文件,如有关设置 Kotlin的文档中所示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 Firebase Cloud Messaging(FCM) 主题与 AWS SNS 结合使用 - How to use Firebase Cloud Messaging(FCM) topic with AWS SNS 在 Kotlin 客户端应用程序中发送 FCM 推送通知 - Firebase 云消息传递 - Sending FCM Push Notification in Kotlin Client App - Firebase Cloud Messaging firebase 云消息的 FCM 令牌有时未注册 - FCM Token for firebase cloud messaging sometimes not registered Firebase 云消息:“超出主题配额” - Firebase Cloud Messaging: "Topic Quota Exceeded" 使用 FCM(Firebase 云消息传递)通过 C# 将推送发送到 Android - Send push to Android by C# using FCM (Firebase Cloud Messaging) Firebase 云消息 (FCM) Api Azure 通知中心的密钥 - Firebase Cloud Messaging (FCM) Api Key for Azure Notification Hub 当我单击 FCM(Firebase 云消息传递)通知时,应用程序重新启动 - When I click on a FCM (Firebase Cloud Messaging) notification, the application restarts 将 FCM(Firebase Cloud Messaging)令牌映射到自定义用户 ID - Mapping FCM(Firebase Cloud Messaging) Token to Custom UserID 从 Firebase 云消息传递中获取 FCM 密钥时出错 - Getting error while fetching FCM key from Firebase cloud messaging Firebase 动态订阅主题 - Firebase subscribe to a topic dynamically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM