Skip to content

Native callback for call rejects - #423

Closed
remigijusbalc wants to merge 6 commits into
react-native-webrtc:masterfrom
remigijusbalc:reject-call
Closed

remigijusbalc wants to merge 6 commits into
react-native-webrtc:masterfrom
remigijusbalc:reject-call

Conversation

@remigijusbalc

Copy link
Copy Markdown

This callback helps in cases when JS context is not loaded and call rejection have to be instantly reported to backend

Comment thread README.md Outdated
@remigijusbalc
remigijusbalc requested a review from sboily May 20, 2021 06:32
@remigijusbalc

Copy link
Copy Markdown
Author

@sboily hey, could you review once more

@khanhduy62

Copy link
Copy Markdown

@remigijusbalc could you help me create an event for cancel a call. My context is when a call is coming and then user press wake/sleep button in order to cancel a call. I really need that event
please help me

@remigijusbalc

remigijusbalc commented May 31, 2021 •

Copy link
Copy Markdown
Author

@khanhduy62 till this PR gets a review, you could just fork my repo and use it like this:

[RNCallKeep setup:@{
@"appName": @"Name",
@"maximumCallGroups": @1,
@"maximumCallsPerCallGroup": @1,
@"supportsVideo": @yES,
@"includesCallsInRecents": @no,
}
callRejectHandler: ^(NSString* uuid, void (^completion)(void)) {

NSString *cancelUrl = @""; // server url
NSString *paramValue = @"value";
NSDictionary *parameters = @{
  @"param": paramValue,
};
NSData *callEndData = [NSJSONSerialization dataWithJSONObject: parameters options: NSJSONWritingPrettyPrinted error: nil];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL: [NSURL URLWithString: cancelUrl]];
[request setHTTPMethod: @"POST"];
[request addValue: @"application/json" forHTTPHeaderField: @"Content-Type"];
[request setHTTPBody: callEndData];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
        if(httpResponse.statusCode == 200) {
          NSError *parseError = nil;
          NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
          NSLog(@"The response is - %@",responseDictionary);
        } else {
          NSLog(@"Error");
        }
 completion();
}];
[dataTask resume];

}];

@khanhduy62

Copy link
Copy Markdown

@remigijusbalc thank you, let me check it :D

@remigijusbalc

Copy link
Copy Markdown
Author

@manuquentin Hey, could you check this out?

@sboily sboily added the need review Need to review ticket label Jun 21, 2021
@sboily

sboily commented Jun 21, 2021

Copy link
Copy Markdown
Member

@manuquentin any feedback? Looks good to me.

@hussainsherwani

Copy link
Copy Markdown

@sboily @manuquentin Any update on this. required feature, if possible please release a new version with this.

@sboily

sboily commented Jul 5, 2021

Copy link
Copy Markdown
Member

Hello @hussainsherwani, sorry we are quite busy for the moment, but yeah we will review it as soon as possible.

@hussainsherwani

Copy link
Copy Markdown

@remigijusbalc I tried with your fork , I am getting an error, could you please help me out
No known class method for selector 'reportNewIncomingCall:handle:handleType:hasVideo:localizedCallerName:supportsHolding:supportsDTMF:supportsGrouping:supportsUngrouping:fromPushKit:payload:withCompletionHandler:'

@remigijusbalc

Copy link
Copy Markdown
Author

@hussainsherwani my fork has another feature - to cancel calls and it's not submitted as PR. You can ignore it by passing "isCancelEvent: NO" to reportNewIncomingCall method in your AppDelegate didReceiveIncomingPushWithPayload method.

@hussainsherwani

Copy link
Copy Markdown

@remigijusbalc Thanks for the quick reply, I tried to add isCancelEvent: NO in reportNewIncomingCall but still error persist.
unable to resolve this.

Screenshot 2021-07-07 at 3 05 02 pm

@remigijusbalc

Copy link
Copy Markdown
Author

Try reinstalling node_modules and pods, then checkouting to this PR commit

@hussainsherwani

Copy link
Copy Markdown

@remigijusbalc Thanks, It was my mistake build successfully, isCancelEvent should be last parameter in reportNewIncomingCall , adding after withCompletionHandler build successfully. Will test it now. Anyway Thanks for the help and Great PR.

@hussainsherwani

Copy link
Copy Markdown

@remigijusbalc could you please help me in one more thing how can I get my notification payload when a call decline as it only give a UUID and we need to send some other values too from notification payload to tell server user declined the call

@remigijusbalc

Copy link
Copy Markdown
Author

@hussainsherwani You could simply save payload in your AppDelegate defined dictionary based on uuid and on callReject callback use it

@hussainsherwani

Copy link
Copy Markdown

hello @remigijusbalc with your forked repo android app not working, getting error error: incompatible types: int cannot be converted to String super.onReject(rejectReason); ^

@linus-komnick

Copy link
Copy Markdown
Contributor

Hey @remigijusbalc & @hussainsherwani,
Shouldn't the rejection event fire immediately when clicking the cancel button? @remigijusbalc I forked your repo but the rejection event only fires when I open the app after canceling the call. Do you know why this is? Is this the same for you or does it fire immediately?

@hussainsherwani

hussainsherwani commented Aug 3, 2021 •

Copy link
Copy Markdown

hey @linus-komnick for me rejection event fire immediately I am using this but in @remigijusbalc forked repo there is an issue for android so when I create android build I use library package for IOS I use forked repo

@linus-komnick

Copy link
Copy Markdown
Contributor

@hussainsherwani thx, I will take note of that!
It's weird though that the cancel event doesn't get triggered in my app. It must be something that I'm doing wrong. My NSLogs don't work either. I'm forced to use post request to log stuff, because NSLog stopped working. So maybe there is a correlation between those two issues...

@linus-komnick

Copy link
Copy Markdown
Contributor

@hussainsherwani In my app the rejection event fires immediately when receiving a voip/pushkit notification. But not when canceling the call. For you it's the other way around, right?

@hussainsherwani

Copy link
Copy Markdown

@remigijusbalc can you please update the PR as there is now a conflict RNCallKeep.m file. @sboily @manuquentin could you please look into this if now you have time

@khushal87

Copy link
Copy Markdown

Hey, @remigijusbalc just to confirm, does this PR solves the issue of not triggering the endCall when the call is rejected when a user presses the reject button in the incoming call? Basically what happens currently is that when a call is rejected through the incoming call the endCall event is triggered which seems weird. So, there's no way of handling the reject call. I have a usecase where the reject call and hangup button should trigger different WS events. But here in both the scenarios, the endCall event is triggered.

@wilmxre

wilmxre commented Sep 28, 2023

Copy link
Copy Markdown

any update on this?

@sboily

sboily commented Oct 17, 2026

Copy link
Copy Markdown
Member

Thanks, and sorry this stalled. Closing: [_answeredCalls setValue:NO forKey:] removes the key instead of storing NO, so the reject check really means "no entry", and the handler also fires for calls that weren't rejected (outgoing calls the user ends, unanswered calls ended by the app). Because the end action is only fulfilled once native code calls the completion, a missing call would also leave CallKit waiting. An app can detect a declined call natively with its own CXCallObserver, and since #877 events received before JS is ready are kept for getInitialEvents.

@sboily sboily closed this Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need review Need to review ticket

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants