mattkhaw / cordova-plugin-callkit Goto Github PK
View Code? Open in Web Editor NEWCordova plugin that enables CallKit + PushKit (iOS) & ConnectionService (Android) functionality to display native UI
License: MIT License
Cordova plugin that enables CallKit + PushKit (iOS) & ConnectionService (Android) functionality to display native UI
License: MIT License
I am using this plugin with the PHP script provided by https://github.com/Hitman666/cordova-ios-voip-push
Basically in your wiki you say that we need to have the following data payload
{
Caller: {
Username: 'Display Name',
ConnectionId: 'Unique Call ID'
}
}
I am using this script with few modifications https://github.com/Hitman666/cordova-ios-voip-push/blob/master/pushSendingScript/simplepush.php
I am getting this error in XCode
2020-09-08 19:09:27.981235+0200 Local[7087:1634806] [objC] didReceiveIncomingPushWithPayload: {
alert = Testing;
data = "{\"Caller\":{\"Username\":\"Alex\",\"ConnectionId\":\"XXXAlex123\"}}";
sound = default;
}
2020-09-08 19:09:27.981415+0200 Local[7087:1634806] [objC] received VoIP message: Testing
2020-09-08 19:09:27.981481+0200 Local[7087:1634806] [objC] received data: (null)
2020-09-08 19:09:27.981939+0200 Local[7087:1634806] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: extra)'
*** First throw call stack:
(0x1a53b9654 0x1a50dbbcc 0x1a540f280 0x1a54188c4 0x1a5295eb8 0x1048ec880 0x1b95a8a3c 0x1062c6338 0x1062c7730 0x1062d5710 0x1a53376bc 0x1a5332590 0x1a5331ba8 0x1af4a1344 0x1a946d3e4 0x104867a38 0x1a51b98f0)
libc++abi.dylib: terminating with uncaught exception of type NSException
Any idea what i am missing?
Looking at the source code here:
https://github.com/mattkhaw/cordova-plugin-callkit/blob/master/src/ios/CordovaCall.m#L584-L588
it looks good to me
Let me first thank you for the merging of those two plugins.
Here is my javascript code of my ionic/react capacitor project:
var push = VoIPPushNotification.init();
push.on('registration', function(data) {
console.log("Registered VOIP push.");
console.log(data);
});
It seems that registration function is never called.
I have added a log into the beginning of VoIPPushNotification.js file and it is printed out.
But then the following logs are not printed:
module.exports = {
init: function(options) {
console.log("Init function called.....");
return new VoIPPushNotification(options);
},
VoIPPushNotification: VoIPPushNotification
};
and this one...
push.on('notification', function(data) {
console.log("[Ionic] notification callback called");
console.log(data);
});
And also the breakpoint at the beginning of following function in VoIPPushNotification.m is never reached:
- (void)init:(CDVInvokedUrlCommand*)command
{
self.VoIPPushCallbackId = command.callbackId;
NSLog(@"[objC] callbackId: %@", self.VoIPPushCallbackId);
//http://stackoverflow.com/questions/27245808/implement-pushkit-and-test-in-development- behavior/28562124#28562124
PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
pushRegistry.delegate = self;
pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
}
Following is what I see in the Xcode console although I haven't called CordovaCall!
APP ACTIVE
To Native Cordova -> CordovaCall init CordovaCall1212087107 ["options": []]
2020-07-14 22:20:16.236592-0700 myTestApp[779:87575] [objC] callbackId: CordovaCall1212087107
WebView loaded
⚡️ To Native -> App addListener 22887397
Can you please let me know what I could have possibly done wrong?
Thanks.
I have successfully implemented iOS integration. But I didn't understand what to do in Android. I'm sending a data notification, then what?
const OneSignal = require('onesignal-node');
const client = new OneSignal.Client(
'***',
'***'
);
client.createNotification({
include_player_ids: ['***'],
content_available: true,
data: {
Caller: {
Username: 'user',
ConnectionId: 'asddasasd',
}
}
});
When I check it with the code below, I can see a notification.
this.oneSignal.handleNotificationReceived().subscribe((res) => {
console.log('Received notif', res)
});
I would appreciate any help.
I've setup cordova-plugin-callkit
on my 2019 project which was broken due to iOS13 CallKit
changes.
I'm receiving VOIP notifications. Callkit screen appears and my js code reacts to the answer event.
I then have 2 issues :
Has anyone managed to run a js-based call system? Or the whole call-part has to be natively run?
Thanks a lot for your plugin @mattkhaw !
The problem I mentioned is only on iOS. I have a code as below. When the user receives the first notification, the reject callback is triggered immediately. When the second notification is sent immediately after, such a problem does not occur.
cordova.plugins.CordovaCall.on('answer', () => {
this.acceptCall();
});
cordova.plugins.CordovaCall.on('reject', () => {
this.closeCall();
});
closeCall:
cordova.plugins.CordovaCall.endCall();
window.twiliovideo.closeRoom();
Hello,
Thank you for your work of combining both of the plugins.
I installed your plugin in Meteor with
meteor add cordova:[email protected]
After that, i am trying to use the VoIPNotification in the code directly, but i am getting the following error
ReferenceError: Can't find variable: VoIPPushNotification
The CordovaCall on the other hand works fine, if i call cordova.plugins.CordovaCall.receiveCall('David Marcus');
,
call is received (if app is in background), but there is a problem:
Answering Takes me to the App, where i have to Answer Yet Again.
Also when i end the call in the app, i have to end the Call in the Native App as well.
This behavior is same on both IOS and Android.
Here is a video displaying the problem:
https://www.dropbox.com/s/gw1ews92f74z640/20200905_172252_1.mp4?dl=0
Also as a bonus point, is it possible to wake the up from the background (does this plugin support VoIP push notifications)?
If it is, how will i be able to achieve that?
Hello,
I am using your plugin to receive VoIP push notifications.
For sending push notifications i am using modified version of https://github.com/Hitman666/cordova-ios-voip-push/blob/master/pushSendingScript/simplepush.php
This works fine when app is open.
When the app is closed or in background, notifications are not coming.
I am using Meteor Cordova and this is on my local machine.
EDIT:
Sometimes when app is in background notification is coming, but i am getting this exception in XCode
Exception NSException * "Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push callback." 0x0000000281a58a20
Here is the code where i am receiving the notification
push.on('notification', function(data) {
Logger.info("notification callback called")
Logger.info(JSON.stringify(data))
if (instance.state.isInBackground) {
instance.state.gotInitiatedInBackground = true
cordova.plugins.CordovaCall.setVideo(true);
cordova.plugins.CordovaCall.receiveCall(data.extra.Username);
}
// do something based on received data
});
We have installed and configured the plugin and, so far, it has worked wonderfully on iOS. So thanks for the work @mattkhaw !!
The only scenario where we are having some trouble with the implementation is the following:
CordovaCall.endCall()
is not executed, and the CallUI notification does not disappear from User As device.Now, this doesn't happen when the app is in the background or foreground, as the JS callback can be executed without any problem.
How can we handle this situation? Is there any functionality of the plugin that could end the call? Maybe from another ( but different) VoIP? Wouldn't that require to register (yet another) call to iOS?
Any help would be greatly appreciated;
Thanks!
Hi! first of all, thanks for taking the time to merge and share with the community these two plugins, and also to reply and comment on each issue (I've read all of them ;).
Now, we have integrated a call/video-call functionality with a heavily modified version of jitsi meet plugin, with our own UI to accept/decline calls. We are now using a normal push notification to inform users about incoming calls, but this is far from ideal as it can be easily missed. We've been searching for solutions to this problem, and we haven't figured out a way to approach it that is valid for both Android and IOs.
FORCING APP TO THE FOREGROUND
This is the first approach we took, using simple push notifications, we forced the main activity from the native side to the foreground and thus we displayed the app UI. This worked for android versions < 10 (As Android 10 prevents apps from starting a new activity when killed), and, of course, this wouldn't work on iOS.
USING FullScreenIntents ON ANDROID
To bypass the Android 10 situation, we found that fullScreen Intents notifications would work wonderfully as it provided a non-intrusive way to notify the user. However, we couldn't find an equivalent functionality on iOS.
USING CallKit
Now, searching for solutions, we stumbled upon this plugin, and it seems that it could provide a valid solution to our problem. However, we are not sure if this is really doable. As I understood from reading your replies and documentation, using VoIP notifications, we could handle them in foreground and background modes and report a call to iOS. This would, however, open the native Call UI that call kit provides, and it seems that there is no workaround to open the custom UI.
It looks like we are stuck using callkit UI. Maybe this reply @mattkhaw wrote a while ago on this issue could help us.
Since Javascript code cannot be executed, the only way to do so is to modify this plugin to just include an instance of CallKit and report a new incoming call then immediately end it so that the screen doesn't appear to trick the app to launch and execute the plugin callback just to run our Javascript code.
Not sure if this could help us in our use case, but I don't fully understand why to terminate the call just after receiving it (I get the execution of the JS part, but not the motivation with ending the call right away if the user will be in a call anyway).
Do you have any insight on how could we implement this feature? Are we stuck with the native UI, and we have to switch and adapt our code to work with it? Thanks!
As far as I understand from the error I got in Xcode I'm sending the data wrong. Cannot JSON serialize.
Error:
[objC] error: -[__NSSingleEntryDictionaryI dataUsingEncoding:]: unrecognized selector sent to instance 0x281c310a0
Incoming data type
NSLog(@"Data type: %@", [data class]);
result:
__NSSingleEntryDictionaryI
The data I send in my PHP script is as follows:
$payload = json_encode( array( 'aps' => array('alert' => 'Test'), 'data' => array( 'Caller' => array('Username' => 'user', 'ConnectionId' => 'user1') ) ) );
...and would like to know if you think it'd be worth adding these changes back to this repo and/or maybe having to make them more "generic" to be able to fulfil both your original purpose (I guess audio only calls?) as well as video calls.
We'll do a WIP PR so you can have a quick look at our changes, you don't have to merge as-is, it's just so you can have a look in case you might be interested in having these changes integrated.
We're also updating cordova-plugin-push
in order to enable video calls on the android side too.
All the best!
First of all congratulations on the work, I would like to know if it is possible to use it on ionic? I'm trying to build a voip using twilio, can this plugin help me?
Hello,
I want to use CallKit with Firebasex plugin but i was hoping you to advice me if this plugin is needed or not in that case.
I am planning to use CordovaCall plugin + firebasex plugin so as i imagine i do not need cordova-ios-voip-push to handle the notifications but i only need to configuration the project to allow background mods for voip/background fetch and remote notification so this means i do not need this current plugin as well or is there anything else i will need this plugin for ?
Any help is appreciated and many thanks for your effort.
In Android 10, answering phone crashes the app.
I have a basic question, does this plugin work when the app is closed? I want to say, does the call screen open when a notification comes while the application is closed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.