voximplant / react-native-demo

React Native Voximplant Demo
173 stars 146 forks source link

Disconnect from VoxImplant client after a while #85

Open hadri3n opened 3 years ago

hadri3n commented 3 years ago

Hi,

First of all, thanks for the great work in offering your demo apps. I am working on an app based on the fully-featured 'VoximplantDemo'.

I am having trouble in maintaining the application available, or at least users "callable" after a while.

Essentially, once the application is in background, the Voximplant will eventually disconnect, and the user become unreachable, and not seem to receive notifications.

For info, I am using the newest version of react-native-firebase in order to support the newest version of Android.

If you have any hints for me, that would be great.

I'm listing the most relevant dependencies I have, below.

 "dependencies": {
    "@react-native-firebase/app": "^12.1.0",
    "@react-native-firebase/messaging": "^12.1.0",
    "@voximplant/react-native-foreground-service": "^2.0.0",
    "react": "17.0.2",
    "react-native": "0.64.2",
    "react-native-callkeep": "^4.2.0",
    "react-native-incall-manager": "^3.3.0",
    "react-native-push-notification": "^7.4.0",
    "react-native-voip-push-notification": "^3.3.0",
    "react-native-voximplant": "^1.24.0",
...
  },
rafaellima94 commented 3 years ago

Hello, any updates on this?

hadri3n commented 3 years ago

None from my part. I have not managed to keep the connection with the client for a long time.

ahammedmishal commented 1 year ago

any updates

rafaellima94 commented 1 year ago

I remember I got it fixed a long time ago, but I don't remember exactly how. On the Voximplant Discord I found my last contributions, you can try to see if it helps :)

on PushManager.ios.js constructor() add at the end

VoipPushNotification.addEventListener('didLoadWithEvents', (events) => {
    if (!events || !Array.isArray(events) || events.length < 1) {
        return;
    }
    for (let voipPushEvent of events) {
        let { name, data } = voipPushEvent;
        if (name === VoipPushNotification.RNVoipPushRemoteNotificationsRegisteredEvent) {
            this.onVoipPushNotificationRegistered(data);
        } else if (name === VoipPushNotification.RNVoipPushRemoteNotificationReceivedEvent) {
            this.onVoipPushNotificationiReceived(data);
        }
    }
});

and register token after

VoipPushNotification.registerVoipToken(); one more thing on AppDelegate.m import pushkit before voip push notification

import <PushKit/PushKit.h> <------

import "RNVoipPushNotificationManager.h"


the calls from ios didn't have audio then i found out that sometimes the generated uuid is not unique, it can be duplicated it is necessary to use react-native-get-random-values to garantee the randomness of the uuid just add to the project and import before uuid hope this information helps somebody


And then I got stuck with an error about expired tokens that I solved looking at this docs

https://voximplant.com/docs/howtos/security/authorize-with-renewable-tokens

Hope I could help Good luck!