Taracque / ionic-plugin-callkit

Ionic/Cordova plugin for CallKit
36 stars 20 forks source link

Improve documentation #6

Closed VadimDez closed 7 years ago

Taracque commented 7 years ago

What is missing in the documentation right now? What needs to be improved? Please be more specific.

VadimDez commented 7 years ago

Give it more structure - split into parts like "What is this, How to install, How to use, Api, etc" Would be very helpful the see the part of how to use it properly.

Taracque commented 7 years ago

Can you please make a fork, and do the changes what you want? Once you are ready please make a pull request.

VadimDez commented 7 years ago

Well i would, but as i said, i don't know how to use this repo.

Taracque commented 7 years ago

Then please be more specific, what part is not clean for you?

VadimDez commented 7 years ago

Would be very helpful the see the part of how to use it properly.

The "how to use" part is not that clear in the actual documentation.

Taracque commented 7 years ago

I guess you know CallKit and what it is doing. In your cordova during the initialization call the callKit.register( callChangedCallback, audioSystemCallback ); call. Once you have and incoming call, use the callKit.reportIncomingCall(name,params, callReportedCallback ); function to report the call to the system. That will display a native callscreen on iOS, and your callChangedCallback will be called when the user answers or declines the call. If the user answered the call, you need to connect the peers and once it is ready, you must call the callKit.callConnected(uuid); function to notify the system, that the call is actually connected. Once the user disconnects the call on the native ui, you will also get a callChangedCallback and once you have disconnected the network session, you have to notify the system wia the callKit.endCall() function.

VadimDez commented 7 years ago

Thanks for you time though! Yes, i figured out this part, but it seems like it doesn't really triggers the native call screen in my case. That's why i wanted to clarify "how to use" part...

What i did is:

document.addEventListener('deviceready', function() {
  var callUUID = '';
  var callKit;

  function callChanged(data) {
    console.log("onCallChanged: "+JSON.stringify(data));
  }

  function audioSystem(data) {
    console.log("onAudioSystem: "+JSON.stringify(data));
  }

  callKit = new CallKit();
  callKit.register( callChanged, audioSystem );

  function incomingCall() {
    callKit.reportIncomingCall('Incoming call', {
      supportsVideo : false,
      supportsGroup: false,
      supportsUngroup: false,
      supportsDTMF: false,
      supportsHold: false
    }, function(uuid) {
      callUUID = uuid;
      console.log('call reported. returned uuid: ' + uuid);
    });
  }

  setTimeout(function () {
    incomingCall();
  }, 10000);
});

What do i see in console:

2017-04-06 18:11:21.089468+0200 CallKit instanced
Provider did reset
RECEIVED AUDIO NOTIFICATION: NSConcreteNotification 0x170055f90 {name = CDVCallKitAudioNotification; object = stopAudio}
RECEIVED CALL CHANGED NOTIFICATION: NSConcreteNotification 0x1740595c0 {name = CDVCallKitCallsChangedNotification; object = <App.CDVCallManager: 0x17022d2a0>}
2017-04-06 18:11:21.113060+0200 onAudioSystem: "stopAudio"
2017-04-06 18:11:31.099754+0200 call reported. returned uuid: DC1468DF-D91D-42C7-A2DD-32879B52316E
Provider did reset
RECEIVED AUDIO NOTIFICATION: NSConcreteNotification 0x170250470 {name = CDVCallKitAudioNotification; object = stopAudio}
RECEIVED CALL CHANGED NOTIFICATION: NSConcreteNotification 0x170250f80 {name = CDVCallKitCallsChangedNotification; object = <App.CDVCallManager: 0x17022d2a0>}
2017-04-06 18:11:31.107635+0200 onAudioSystem: "stopAudio"

I used setTimeout to simulate incoming call. The problem is that the call screen is not triggered on reportIncomingCall. Did i do anything wrong or i missed something ?

Taracque commented 7 years ago

I hope you run it on a device, not in simulator. CallKit does not work in the iOS Simulator, so your app will need to be run on a device instead.

VadimDez commented 7 years ago

Yes, i did test it on a real device

Taracque commented 7 years ago

The provider did reset means, that the call has been reseted by the system. Can you please try to move var callKit; out from the document.addEventListener? (to make it global)

VadimDez commented 7 years ago

No success. Still seeing Provider did reset and onAudioSystem: "stopAudio" two times

Taracque commented 7 years ago

Than please check than you have Background Modes Voice over IP enabled four your app target in Capabilities. Otherwise CallKit will not work.

VadimDez commented 7 years ago

Ok, got it now. Background Modes was on but not the Voice over IP. I'll make a pull request with updated documentation. Thanks!