react-native-webrtc / react-native-callkeep

iOS CallKit framework and Android ConnectionService for React Native
ISC License
897 stars 437 forks source link

[RNCallKeepModule] displayIncomingCall ignored due to no ConnectionService or no phone account #678

Open wilmxre opened 1 year ago

wilmxre commented 1 year ago

Bug report

Description

In some Lenovo devices the incoming call is not showing up, neither the outgoing calls are received. The isConnectionServiceAvailable method returns true so the problem must reside in the 'no phone account' part. For some reason the setup is returning false too. This is how my options looks like:

android: {
    selfManaged: true,
    alertTitle: 'Permissions required',
    alertDescription: 'This application needs to access your phone accounts',
    cancelButton: 'Cancel',
    okButton: 'ok',
    additionalPermissions: [PermissionsAndroid.PERMISSIONS.READ_CONTACTS],
    imageName: 'logo',
    // Required to get audio in background when using Android 11
    foregroundService: {
      channelId: 'CallKeepService',
      channelName: APP_NAME,
      notificationTitle: 'App running in background',
      notificationIcon: '../../assets/icons/app-icon.png',
    },
  },
  ios: {
    appName: APP_NAME,
    maximumCallGroups: '1',
    maximumCallsPerCallGroup: '1',
    includesCallsInRecents: false,
    supportsVideo: true,
  },

I tried to go to calling accounts with hasDefaultPhoneAccount, but this just navigates me to an empty screen with Calling accounts header title. My app is not available in this list. What should i do to enable calling in this tablet? How can i register my app as a calling app?

Steps to Reproduce

Versions

- Callkeep: 4.3.3
- React Native: 0.70.5
- iOS:
- Android: 11
- Phone model: Lenovo TB-X306F

Logs

[RNCallKeepModule] updating react context
[RNCallKeepModule] setup
[VoiceConnectionService] setAvailable: false
 [VoiceConnectionService] setInitialized: true
[RNCallKeepModule] setSettings: { NativeMap: {"alertDescription":"This application needs to access your phone accounts","cancelButton":"Cancel","alertTitle":"Permissions required","foregroundService":{"channelId":"CallKeepService","channelName":"x Elder","notificationTitle":"App running in background","notificationIcon":"../../assets/icons/app-icon.png"},"okButton":"ok","selfManaged":true,"imageName":"logo","additionalPermissions":["android.permission.READ_CONTACTS"]} }
[RNCallKeepModule] API Version supports self managed, and is enabled in setup
 [RNCallKeepModule] setup, adding RECORD_AUDIO in permissions in self managed
  [RNCallKeepModule] registerPhoneAccount
[RNCallKeepModule][registerPhoneAccount] CAPABILITY_SELF_MANAGED.
 [RNCallKeepModule] registerEvents
[RNCallKeepModule] startObserving, event count: 0
 [RNCallKeepModule] startObserving, event count: 0
[VoiceConnectionService] setAvailable: true
 [VoiceConnectionService] setInitialized: true
[VoiceConnectionService] setAvailable: true
[VoiceConnectionService] setInitialized: true
[VoiceConnectionService] setCanMakeMultipleCalls: true
[RNCallKeepModule] displayIncomingCall ignored due to no ConnectionService or no phone account
[RNCallKeepModule] reportEndCallWithUUID, uuid: ac348c38-24b5-4910-9bdb-e9bd220869d0, reason: 2
guptayush02 commented 1 year ago

I am facing the same issue in one plus, please let me know if you solve this.

wilmxre commented 1 year ago

callkeep uses telecom manager to show the incoming calls and for that it needs to register a phone account. some devices are just not capable for that, in my case i had the config_voice_capable flag false, so the registration is not possible. i made a workaround for devices that don't have phone accounts, but these devices could not wake up from killed state with this implementaton, it only works in foreground and background state.

guptayush02 commented 1 year ago

I am using messaging().setBackgroundMessageHandler() to wake up my app @react-native-firebase/messaging

guptayush02 commented 1 year ago

I fixed the issue refer https://github.com/react-native-webrtc/react-native-callkeep/tree/master/example

Check all the permission from AndroidMnifest.xml and then call the function

const RNCall = async() => {
    const options = {
      ios: {
        appName: 'My app name',
      },
      android: {
        alertTitle: 'Permissions required',
        alertDescription: 'This application needs to access your phone accounts',
        cancelButton: 'Cancel',
        okButton: 'ok',
        imageName: 'phone_account_icon',
        additionalPermissions: [PermissionsAndroid.PERMISSIONS.RECORD_AUDIO],
        // Required to get audio in background when using Android 11
        foregroundService: {
          channelId: 'com.company.my',
          channelName: 'Foreground service for my app',
          notificationTitle: 'My app is running on background',
          notificationIcon: 'Path to the resource icon of the notification',
        }, 
      }
    };

    const result = await RNCallKeep.setup(options).then(accepted => {
      console.log("accepted--->", accepted)
    });
    const callUUID = '1234567890'; // a unique identifier for the call
    const handle = 'John Doe'; // the caller's name or phone number
    const localizedCallerName = 'John Doe'; // the localized caller name to display in the notification
    const handleType = 'number'; // the type of handle (e.g. 'generic', 'number', 'email', etc.)
    const hasVideo = false; // whether the call has video

    RNCallKeep.displayIncomingCall(callUUID, handle, handleType);
    RNCallKeep.isCallActive(callUUID);

  }