0
const TASK_NAME = "VIDEO_CALL_TASK";

TaskManager.defineTask(TASK_NAME, async () => {
  try {
    let newSocket = io("wss://url");
    
    newSocket.on("error", (e) => {
      console.log("socket error is ", e);
    });

    newSocket.on("callUser", async (data) => {
      console.log("someone is calling me", data);
      await AsyncStorage.setItem("fromPeer", data.fromPeer);
      await AsyncStorage.setItem("fromSocket", data.fromSocket);
    });

    console.log("new socket", newSocket);

    const jsonValue = JSON.stringify(newSocket);
    await AsyncStorage.setItem("socket", jsonValue);

    return BackgroundFetch.Result.NewData;

  } catch (e) {

    console.log(e);

  }
});

the task is start after 5 sec and running the showing the log of socket i created.

but when i call this user from other user it doest not listen the socket event and run the callback.

0 Answers0