react-native-callkeep icon indicating copy to clipboard operation
react-native-callkeep copied to clipboard

How call declines/rejects ios are handled in ios

Open remigijusbalc opened this issue 4 years ago • 42 comments

Just wondering how anyone handles call declines/rejects when app is not opened in ios?

remigijusbalc avatar May 13 '21 14:05 remigijusbalc

Have you checked this

Romick2005 avatar May 13 '21 18:05 Romick2005

I did. I guess it would be better to use delegation and implement required specific ones instead of callback for all of them.

remigijusbalc avatar May 17 '21 06:05 remigijusbalc

It is just event based callback you can use only one that you are interested in. Because function sendEventWithName is called anyway and you cannot stop it with those delegation.

Romick2005 avatar May 17 '21 07:05 Romick2005

But what about call initiator hang-up call, how do you handle that situation? Since ios 13 every voip push should fire reportNewIncomingCall. I saw that some people fire this and immediately end call but that doesn't sound reliable. Maby FCM pushes would be the way to go?

remigijusbalc avatar May 17 '21 11:05 remigijusbalc

Hey @Romick2005 with your fork following functions to end call does not worked as they are not remove swipe to start screen of call from lock screen in iOS and it is working perfectly in case of receiving RNCallKeepPerformAnswerCallAction in didLoadWithEvents.

RNCallKeep.endCall(call_uuid) RNCallKeep.rejectCall(call_uuid) RNCallKeep.endAllCall()

With current version of react-native-callkeep : 4.2.0 above functions to end call working perfectly but didLoadWithEvents does not give RNCallKeepPerformAnswerCallAction event when app load.

Please guide me if you have any idea to figured it out.

krupalikevadiya avatar Jun 10 '21 11:06 krupalikevadiya

It is not clear what do you mean by "not remove swipe to start screen of call from lock screen in iOS"? I assume that you are talking about two cases when app is closed and 1) Phone is locked - need to enter code or faceId to unlock. 2) Phone is unlocked. So there also are two cases how js part of the app receives the event: 1) js loaded then you need to listen NewIncomingCallEvent if event was fired, but was not captured by js side then you have to listen didLoadWithEvents. I am bot sure what is not working for you. Can you please describe your problem with more details.

Romick2005 avatar Jun 10 '21 15:06 Romick2005

@remigijusbalc How were you able to handle when call initiator hangs-up the call? Ideally I want to stop showing the call ui screen(CallKit) and display a missed call notification when the call initiator ends the call before it is picked by the receiver.

How can I do this please

nero2009 avatar Jul 20 '21 21:07 nero2009

@Romick2005 in ios on the lock screen when I accept call it not asking the user to unlock his/her phone like in messenger and in slack or any other app why is that so at least it should ask to enter a pass or unlock using face id

shaheem-khanzada avatar Jul 29 '21 22:07 shaheem-khanzada

@shaheem-khanzada I think that it is actually required to unlock the phone to start/show app UI. I think you are using faceId and you did not notice how it actually unlock a phone when you look at the phone and doing call accept.

Romick2005 avatar Jul 30 '21 06:07 Romick2005

@Romick2005 I just saw when we accept the call from the lock screen our app start but we cannot see the screen but we can see the logs which I implement in the screen where I am navigating user on call accept so it means we can accept the call in lock screen also using react-native am I right?

shaheem-khanzada avatar Jul 30 '21 14:07 shaheem-khanzada

Your app automatically starts when it receives voip push notification on iOS (or with high priority push on Android). That is actually causing apple CallKit UI to show app, and from this point your app get limited functionality control.

Romick2005 avatar Jul 30 '21 16:07 Romick2005

@Romick2005 I mean I can see my consoles in React-Native Screens my simple question is can we connect calls on the lock screen when we press accept on the lock screen

shaheem-khanzada avatar Jul 30 '21 18:07 shaheem-khanzada

My simple answer is yes.

Romick2005 avatar Jul 30 '21 18:07 Romick2005

@Romick2005 Do you know if it's possible to use endCall from AppDelegate.m?

linus-komnick avatar Aug 04 '21 20:08 linus-komnick

Yes it is possible.

Romick2005 avatar Aug 04 '21 20:08 Romick2005

@Romick2005 How do I do that?

linus-komnick avatar Aug 04 '21 20:08 linus-komnick

[RNCallKeep endCallWithUUID: callUUID reason: [reasonId intValue]]; This answer can also help you.

Romick2005 avatar Aug 04 '21 20:08 Romick2005

@Romick2005 how we can listen to this event on AppDelegate like onEndCall press from native screen ?

shaheem-khanzada avatar Aug 04 '21 20:08 shaheem-khanzada

this

Have you check this?

Romick2005 avatar Aug 04 '21 20:08 Romick2005

@Romick2005 Hm, it says: Use of undeclared identifier 'reasonId'

linus-komnick avatar Aug 04 '21 20:08 linus-komnick

Because it is variable value

Romick2005 avatar Aug 04 '21 20:08 Romick2005

@Romick2005 I'm almost there I think. This time I get "Bad receiver type 'int'". This is my code: int reasonId = 6; [RNCallKeep endCallWithUUID: callId reason: [reasonId intValue]];

linus-komnick avatar Aug 04 '21 20:08 linus-komnick

RNCallKeep endCallWithUUID: callId reason: [reasonId intValue]]

[RNCallKeep endCallWithUUID: callId reason: @6]

Romick2005 avatar Aug 04 '21 20:08 Romick2005

It works flawlessly! Thank you so much @Romick2005!!! I would've spent countless more hours on this... If there's anything I can do for you, let me know!

linus-komnick avatar Aug 04 '21 21:08 linus-komnick

Hi @linus-komnick, can you please share small code sample how do you handle silent push notifications with end call functionality? Also what do you use for sending push notifications?

Romick2005 avatar Aug 06 '21 16:08 Romick2005

@Romick2005 Sure, I use this library: https://www.npmjs.com/package/apn

linus-komnick avatar Aug 06 '21 17:08 linus-komnick

I have a lesson right now, I'll send you the code sample in an hour!

linus-komnick avatar Aug 06 '21 17:08 linus-komnick

@Romick2005 This is how I do it:

const apn = require('apn');

const options = {
  token: {
    key: 'APNKey.p8',
    keyId: process.env.KEY_ID,
    teamId: process.env.TEAM_ID
  },
  production: true  
};

let note = new apn.Notification();

note.alert = "Call canceled by caller";
note.topic = "com.bundle.id";
note.contentAvailable = 1;

const apnProvider = new apn.Provider(options);

apnProvider.send(note, deviceToken);

apnProvider.shutdown();

linus-komnick avatar Aug 06 '21 19:08 linus-komnick

Great! Thank you! I am also interested how do you handle this silent push notifications on native side in objective-c?

Romick2005 avatar Aug 08 '21 02:08 Romick2005

Sure, this is how I do it:

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
    NSString *callId = [[NSUserDefaults standardUserDefaults] stringForKey:@"callId"];

    int reasonId = 6;
    [RNCallKeep endCallWithUUID: callId reason: reasonId];

    completionHandler(UIBackgroundFetchResultNewData);
}

linus-komnick avatar Aug 08 '21 07:08 linus-komnick