Giter VIP home page Giter VIP logo

jonz94 / capacitor-sim Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 2.0 740 KB

⚡️ Capacitor plugin to get information from device's sim cards.

Home Page: https://www.npmjs.com/package/@jonz94/capacitor-sim

License: BSD Zero Clause License

Ruby 8.02% Java 10.26% TypeScript 15.79% Swift 17.99% Objective-C 5.52% JavaScript 3.91% Kotlin 38.51%
android capacitor capacitor-android capacitor-plugin ios capacitor-ios sim-card

capacitor-sim's People

Contributors

jonz94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

capacitor-sim's Issues

how do i get the event of the allowed permission?

Hey i want to update my phone number component when I'm actaually getting the value of the phone number. I'm using next.js
Also the country code overrides the phonenumber value completely

"use client";

import { useState, useEffect } from "react";
import PhoneInput from "react-phone-input-2";
import "react-phone-input-2/lib/style.css";
import { GetSimCardsResult, Sim, SimCard } from "@jonz94/capacitor-sim";
import { Capacitor } from "@capacitor/core";
const simIsAvailable = Capacitor.isPluginAvailable('Sim');

export default function PhoneInputBox() {
  const [phone, setPhone] = useState("");
  const [country, setCountry] = useState("us");
  if (simIsAvailable) {
    useEffect(() => {
      let hasPermission = true;
      Sim.requestPermissions().then((permStatus) => {
        hasPermission = permStatus.readSimCard === "granted";
      })
      if (hasPermission) {
        Sim.getSimCards().then(async (result: GetSimCardsResult) => {
          const simCard: SimCard = await result.simCards[0];
          setPhone(simCard.number);
          setCountry(simCard.isoCountryCode)
        })
      }
    }, []);
  }
  return (
    <PhoneInput
      value={phone}
      onChange={(phone) => setPhone(phone)}
    />
  );
}

Unable to Retrieve SIM Card Information on Latest iOS Version

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.