Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] - Receive call with app in background or closed on iOS #1660

Open
samuelvertello opened this issue Jan 29, 2025 · 4 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@samuelvertello
Copy link

  • [ ] @stream-io/video-react-sdk
  • [X ] @stream-io/video-react-native-sdk
  • [ ] @stream-io/video-client

Describe the bug
I'm using @stream-io/video-react-native-sdk in my project, and it's working perfectly for Android. I can receive the call with the app in the background or closed, but for iOS I only receive it if the app is in the foreground.

Has this been fixed in a newer version?

"Version"
"@stream-io/video-react-native-sdk": "^1.9.0",
"@stream-io/react-native-webrtc": "^125.0.3",]

@samuelvertello samuelvertello added the bug Something isn't working label Jan 29, 2025
@kristian-mkd
Copy link
Contributor

Hi @samuelvertello, we can reproduce the reported issue, thanks for reporting. We will work on fixing it and inform here as soon as it is fixed.

@santhoshvai
Copy link
Member

@samuelvertello Can you send your setPushConfig setup

Also make sure that you use

    const client = StreamVideoClient.getOrCreateInstance({
        apiKey,
        user,
        tokenProvider,
      });

Whereever you create a video client

@samuelvertello
Copy link
Author

the setPushConfig configuration is not very different from the documentation. it is like this.

import {
StreamVideoClient,
StreamVideoRN,
} from "@stream-io/video-react-native-sdk";
import { AndroidImportance } from "@notifee/react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";

const STREAM_API_KEY = process.env.EXPO_PUBLIC_STREAM_API_KEY;

export async function setPushConfig() {
try {
const userId = await AsyncStorage.getItem("@userid");
const userName = await AsyncStorage.getItem("@userName");
const userToken = await AsyncStorage.getItem("@usertoken");

if (!userId || !userName || !userToken) {
  console.log("User not authenticated or invalid token");
  return;
}
StreamVideoRN.setPushConfig({
  isExpo: true,
  ios: {
    pushProviderName: __DEV__
      ? "apn-video-staging"
      : "apn-video-production",
  },
  android: {
    pushProviderName: __DEV__
      ? "firebase-video-dev"
      : "firebase-video-production",
    incomingCallChannel: {
      id: "stream_incoming_call",
      name: "Incoming call notifications",
      importance: AndroidImportance.HIGH,
      vibration: true,
      vibrationPattern: [300, 500],
    },
    incomingCallNotificationTextGetters: {
      getTitle: (createdUserName) => `Ligação de ${createdUserName}`,
      getBody: () => "Toque para atender a chamada",
    },
  },
  createStreamVideoClient: async () => {
    return StreamVideoClient.getOrCreateInstance({
      apiKey: STREAM_API_KEY,
      user: {
        id: JSON.parse(userId),
        name: JSON.parse(userName),
      },
      token: JSON.parse(userToken),
    });
  },
});

console.log("Stream Push Config successfully set up.");

} catch (error) {
console.error("Error setting up Stream Push Config:", error);
}
}

@samuelvertello
Copy link
Author

outside the react lifecycle
in index.js i call my notifee listeners function

import {
isNotifeeStreamVideoEvent,
oniOSNotifeeEvent,
} from "@stream-io/video-react-native-sdk";
import { Platform } from "react-native";
import notifee from "@notifee/react-native";

export const setNotifeeListeners = () => {
notifee.onBackgroundEvent(async (event) => {
if (isNotifeeStreamVideoEvent(event)) {
}
if (Platform.OS === "ios") {
oniOSNotifeeEvent({ event, isBackground: true });
}
});

notifee.onForegroundEvent(async (event) => {
if (isNotifeeStreamVideoEvent(event)) {
}
if (Platform.OS === "ios") {
oniOSNotifeeEvent({ event, isBackground: false });
}
});
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants