pbakondy / cordova-plugin-sim

:cherries: A cordova plugin to get the device's SIM data (carrier name, mcc mnc, country code, telephonenumber, etc)
MIT License
163 stars 100 forks source link

Add `callState` to iOS #57

Open mark-veenstra opened 7 years ago

mark-veenstra commented 7 years ago

Expected behaviour

I would like to get the current call state on an iOS device, just like the Android equivalent callState

Actual behaviour

callState now unavailable on iOS

I'm seeing this behaviour on

I am using

Hardware models

iPhone 6s, iPad Air 2

OS versions

iOS 9.2, iOS 10.x

I've checked these

So how can we reproduce this?

Since this option has not been build yet into this plugin and I am not well known with Switch / Objective-C here some examples / help to get this done:

A plugin which uses the CTCallCenter and CTCall to get the info: https://github.com/ElieSauveterre/cordova-phone-call-trap/blob/master/src/ios/CDVPhoneCallTrap.m

And some related SO info: http://stackoverflow.com/a/10942370/1800695

akash-pal commented 7 years ago

Following are the results from 3 different ios devices:

1. iphone 6 plus (Without SIM Card) {"countryCode":"","mnc":"","mcc":"","carrierName":"Vodafone India","allowsVOIP":true}

2.ipad (Without SIM Card) {"countryCode":"","mnc":"","mcc":"","carrierName":"","allowsVOIP":true}

3. iphone 6 (WITH SIM) {"countryCode":"in","mnc":"27","mcc":"404","carrierName":"Vodafone India","allowsVOIP":true}

How to differentiated which device support call facility or not ?

mark-veenstra commented 7 years ago

Well having a sim or not does not tell you anything about the call state. For example if you have NO sim, but you have a VOIP app installed the call state can still be off hook etc.

Same goes for Android. The TelephonyManager returns the calling state for SIM, VoIP or any other calling application (Skype, FaceTime etc etc.)

So the call state is not only related to a SIM it is related to the call state which could be SIM, VOIP or ....