Home > Software design >  Kotlin: Subscribe to Firebase Cloud Messaging(FCM) Topic
Kotlin: Subscribe to Firebase Cloud Messaging(FCM) Topic

Time:02-08

I've used the Android (Java) way of doing things before for subscribing to a topic

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

But was looking at the Kotlin example

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

I'm not finding how to get this class to show to be able to write it like the above.

I can get the Java way to show but not the Kotlin.

Anyone know what needs to be added to the Gradle or other to do this?

Thanks

CodePudding user response:

My guess it that you forgot to add the Kotlin extensions, which means you only get the Java-level APIs.

To make the Kotlin extensions available, add the -ktx dependency to your Gradle file as shown in the documentation on setting up Kotlin.

  •  Tags:  
  • Related