https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
h

Haruki

03/01/2023, 3:01 AM
Hi there, (I am posting this here because #firebase looks like no one is responding.) I'm interested in using Firebase Cloud Messaging in my WEB project (React and Kotlin/JS) and I'm wondering if you could help me out. Specifically, I'm trying to figure out how to integrate the FCM JavaScript API into Kotlin code. I only see javascript codes in FCM documentations, and I am wondering if we can simply code in Kotlin because I was able to use the WebSocket JavaScript API in Kotlin by modifying the code like this: [javascript]
Copy code
let socket = new WebSocket("<wss://javascript.info/article/websocket/demo/hello>");
to [kotlin]
Copy code
val socket = WebSocket("<wss://javascript.info/article/websocket/demo/hello>")
Is there a similar approach I can take to use the FCM JavaScript API in my project? In other words, is it possible to code this in Kotlin?
Copy code
import { initializeApp } from "firebase/app";
import { getMessaging } from "firebase/messaging";

// TODO: Replace the following with your app's Firebase project configuration
// See: <https://firebase.google.com/docs/web/learn-more#config-object>
const firebaseConfig = {
  // ...
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);


// Initialize Firebase Cloud Messaging and get a reference to the service
const messaging = getMessaging(app);
Any guidance you can provide would be greatly appreciated. Thanks in advance for your help!