jonz94 / capacitor-sim

⚡️ Capacitor plugin to get information from device's sim cards.
https://www.npmjs.com/package/@jonz94/capacitor-sim
BSD Zero Clause License
17 stars 2 forks source link

Unable to Retrieve SIM Card Information on Latest iOS Version #8

Open kevindupas opened 1 year ago

kevindupas commented 1 year ago

Unable to Retrieve SIM Card Information on iOS Version 16.4.1

Description:
On iOS version 16.4.1, it has become impossible to retrieve the SIM card information using the getSimCards() function. This issue affects iPhone 12 with iOS 16.4.1. The function works correctly on iPhone 12 with iOS 16.3.1.

Relevant Information:

  1. iPhone 12 - iOS Version: 16.4.1 (Issue occurs)

    • To Native -> Sim getSimCards 96**
    • TO JS {"simCards":[{"mobileCountryCode":"65535","mobileNetworkCode":"65535","carrierName":"--","allowsVOIP":true,"isoCountryCode":"--"},{"mobileCountryCode":"65535","allowsVOIP":true,"carrierName":"--","isoCountryCode":"--","mobileNetworkCode":"65535"}]}
  2. iPhone 12 - iOS Version: 16.3.1 (Works as expected)

    • To Native -> Sim getSimCards 1117**
    • TO JS {"simCards":[{"carrierName":"","isoCountryCode":"","mobileCountryCode":"","mobileNetworkCode":"","allowsVOIP":true},{"isoCountryCode":"fr","carrierName":"Orange France","mobileNetworkCode":"01","mobileCountryCode":"208","allowsVOIP":true}]}
  3. iPhone XR - iOS Version: 16.3.1 (Works as expected)

    • To Native -> Sim getSimCards 1138****
    • TO JS {"simCards":[{"isoCountryCode":"fr","carrierName":"Orange France","mobileNetworkCode":"01","mobileCountryCode":"208","allowsVOIP":true},{"carrierName":"","isoCountryCode":"","mobileCountryCode":"","mobileNetworkCode":"","allowsVOIP":true}]}

Code Example:

async function getSimCards() {
    try {
        const { simCards } = await Sim.getSimCards();

        const sortedSimCards = simCards.map(
            ({
                number, allowsVOIP, carrierName, isoCountryCode, mobileCountryCode, mobileNetworkCode,
            }) => ({
                number,
                allowsVOIP,
                carrierName,
                isoCountryCode,
                mobileCountryCode,
                mobileNetworkCode,
            }),
        );

        setSimInfo(sortedSimCards);
    } catch (error) {
        console.error('Error getting SIM info:', error);
        setSimError('Erreur lors de la récupération des informations de la carte SIM');
    }
}

Please help me fix this issue on the latest iOS version.

jonz94 commented 1 year ago

Sorry for the late reply...

I can reproduce this issue on my end. This plugin works as expected on iOS 16.3.1 but no longer works on iOS 16.4.

Unfortunately, after some investigation, I have bad news to share:

I found the following comments in the CTCarrier.h file:

To provide some context, this plugin uses Core Telephony CTCarrier API provided by Apple under the hood to retrieve the SIM card information.

Now, it seems that Apple does not allow us to do so... I suspect it is due to privacy reasons...

Until Apple re-adds this feature for developers, I don't think there is much we can do for now.

sinanverve7 commented 1 year ago

@kevindupas hi kevin did you found any workaround ?

sinanverve7 commented 1 year ago

@jonz94 any updates ?

officialomkarjadhav commented 1 year ago

Error getting SIM info: [Error: "Sim" plugin is not implemented on web]

getting this error!!! ? @jonz94

jonz94 commented 1 year ago

Error getting SIM info: [Error: "Sim" plugin is not implemented on web]

getting this error!!! ? @jonz94

@officialomkarjadhav

This sim card plugin only work when running the app as native android/ios app.

Because it is not possible to get sim card information on the web platform.

jonz94 commented 1 year ago

@sinanverve7 Currently, it is not possible to get SIM card information on iOS 16.4+ because Apple does not allow it.

I am still looking for an alternative way to achieve the same goal, but right now, it seems like there is no hope to make it work.

officialomkarjadhav commented 1 year ago

Error getting SIM info: [Error: "Sim" plugin is not implemented on web] getting this error!!! ? @jonz94

@officialomkarjadhav

This sim card plugin only work when running the app as native android/ios app.

Because it is not possible to get sim card information on the web platform.

thank you for your reply but i am using it in react native -expo not in web @jonz94

jonz94 commented 1 year ago

@officialomkarjadhav Would you like to open a new issue and provide more details? I believe your issue is not related to the original issue of this thread. Thank you!

P.S. I'm not familiar with "React Native / Expo" development, so I'm not sure if using a capacitor plugin in a React Native project is a good idea or not.

kantharia commented 1 year ago

@jonz94 - Is there alternate way to do it? I've seen one financial app that could check if the SIM card was present or not. Does Apple have something special provision for financial apps, like a Private-API access?

vijay894com commented 3 months ago

Any update on this.