twilio / twilio-voice-react-native

Other
62 stars 22 forks source link

Incoming CallInvite is not working in Android #329

Open manpreetaj opened 4 months ago

manpreetaj commented 4 months ago

Issue

Pre-submission Checklist

Description

Currently using 'twilio-voice-react-native' SDK version '1.0.0-beta.4'. Previously, I could receive the CallInvite for incoming calls on an Android 10 device (also on Android12) with this SDK version. But now, the CallInvite emitter is no longer triggered without any code changes. However, the app is still able to receive the push notification payload for incoming calls.

Successfully able to register the access token on voice. voice.register(accessToken)

voice.on(Voice.Event.Registered, () => { console.log('Device registered successfully for incoming calls.') });

LOG Device registered successfully for incoming calls.

Reproduction Steps

Expected Behavior

When receive incoming call, the callInvite emitter should be triggered automatically to accept/reject the calls.

Actual Behavior

Currently device is able to receive the push data payload but notification doesn't shows and callInvite not triggred. When check the call logs on Twilio console it shows following errors: Error 52103GCM/FCM client uninstalled or turned off notifications

52116Legacy FCM server key used to send notifications

52116Legacy FCM server key used to send notifications

Reproduction Frequency

Is the reproducibility of the issue deterministic? If not, what percentage of the time does the issue occur? In how many attempts was the issue observed?

Screenshots

Software and Device Information

Please complete the following information. Device: Samsung SM-M115F Android 10.

Additional Context

Add any other context about the problem here.

afalls-twilio commented 4 months ago

@manpreetaj we highly recommend you upgrade to use FCM v1 tokens as by June 2024, Google will be disabling FCM legacy support.

Also, what do you mean by "the callInvite emitter should be triggered automatically to accept/reject the calls"? are you receiving a firebase notification (you can test by putting a breakpoint here).

manpreetaj commented 4 months ago

@afalls-twilio Thank you, I will attempt to upgrade to FCM v1 tokens.

Q: Also, what do you mean by "the callInvite emitter should be triggered automatically to accept/reject the calls"? are you receiving a firebase notification.

Ans: This implies that upon receiving an incoming call, the voice.on('callInvite', (callInvite) => {callInvite.accept()}) listener must be invoked, as it was previously. This allows for the action of accepting or rejecting the incoming call to be performed. Currently, the app is capable of receiving the 'remoteMessage' payload for incoming calls within the following 'react-native-firebase' class.

 import messaging from '@react-native-firebase/messaging';

 messaging().onMessage(async remoteMessage => {
    console.log('Message received!', remoteMessage);
  });

However, the class VoiceFirebaseMessagingService.java is unable to retrieve the remoteMessage.

 @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    logger.debug("onMessageReceived remoteMessage: " + remoteMessage.toString());
   }
afalls-twilio commented 4 months ago

@manpreetaj I'm guessing you are running two firebase services, one via the @react-native-firebase/messaging module and one internal to our SDK?

Ahh, so you are not receiving a message in VoiceFirebaseMessagingService.java? can you make sure that both Firebase services (NodeJS and VoiceFirebaseMessagingService.java) are receiving the same firebase token?

Also, what happens when you delete your app entirely, then re-install it to force it to create a new FCM token for both sercices?

manish-shrivastava commented 3 months ago

I have also got the same issue @afalls-twilio. Can you suggest what solution worked for you @manpreetaj ?

manpreetaj commented 3 months ago

@manish-shrivastava The following solutions have worked for me:

1) Upgrade to use FCM v1 tokens as by June 2024, Google will be disabling FCM legacy support. Click here for more information.

2) Specify the service and receiver in the app's manifest file.

<service
            android:name="com.twiliovoicereactnative.VoiceFirebaseMessagingService"
            android:stopWithTask="false"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <receiver
            android:name="com.twiliovoicereactnative.VoiceNotificationReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="ACTION_INCOMING_CALL" />
                <action android:name="ACTION_ACCEPT_CALL" />
                <action android:name="ACTION_REJECT_CALL" />
                <action android:name="ACTION_CANCEL_CALL" />
                <action android:name="ACTION_CALL_DISCONNECT" />
                <action android:name="ACTION_RAISE_OUTGOING_CALL_NOTIFICATION" />
                <action android:name="ACTION_CANCEL_NOTIFICATION" />
                <action android:name="ACTION_FOREGROUND_AND_DEPRIORITIZE_INCOMING_CALL_NOTIFICATION" />
                <action android:name="ACTION_FOREGROUND_APPLICATION" />
            </intent-filter>
    </receiver>
mhuynh5757 commented 3 months ago

Hi all, thanks for the vibrant community discussion and problem solving. We're currently working on improving our docs and will be including this feedback in our revisions. Please stay tuned for that! I'll keep this issue pinned and open for now, and close it out when we release those documentation changes.

afalls-twilio commented 1 month ago

@manpreetaj what version are you using?

The reason I ask is because..

1) We no longer have a receiver, it has been migrated to a separate service 2) The manifest merging stage of your build should merge the correct manifest settings from the .aar package for our sdk (it has a manifest inside of it).

manpreetaj commented 1 month ago

@afalls-twilio Currently, I'm using @twilio/voice-react-native-sdk": "^1.0.0" and I noticed it has a separate service.

Thanks for the update.