[英]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.