コード例 #1
0
        private DeviceCountryIdentifier(IMvxLogProvider mvxLogProvider)
        {
            _log = mvxLogProvider.GetLogFor <DeviceCountryIdentifier>();
            _telephonyManager = new CTTelephonyNetworkInfo();

            _log.Debug(_telephonyManager == null ? $"{nameof(CTTelephonyNetworkInfo)} is null" : $"{nameof(CTTelephonyNetworkInfo)} is not null");
        }
コード例 #2
0
 static string GetCarrierName()
 {
     using (var info = new CTTelephonyNetworkInfo())
     {
         return info.SubscriberCellularProvider.CarrierName;
     }
 }
コード例 #3
0
ファイル: NetworkService.cs プロジェクト: tvvister91/Arena
 private void GetNetworkSetup(NetworkReachabilityFlags flags)
 {
     //  we're on wifi here
     if (flags.HasFlag(NetworkReachabilityFlags.IsWWAN))
     {
         //  what type of connectivity is available
         CTTelephonyNetworkInfo info = new CTTelephonyNetworkInfo();
         System.Diagnostics.Debug.WriteLine($"*** {GetType().Name}.{nameof(GetNetworkSetup)} - Cellular detected: {info.DebugDescription}");
         if ((info.CurrentRadioAccessTechnology == CTRadioAccessTechnology.GPRS) || (info.CurrentRadioAccessTechnology == CTRadioAccessTechnology.Edge))
         {
             ConnectionState = NetworkConnectionStates.CellularSlow;
             System.Diagnostics.Debug.WriteLine("Network Service - Connection speed designated to be SLOW.");
         }
         else
         {
             ConnectionState = NetworkConnectionStates.CellularFast;
             System.Diagnostics.Debug.WriteLine("Network Service - Connection speed designated to be FAST.");
         }
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("Network Service - WIFI detected.");
         ConnectionState = NetworkConnectionStates.Wifi;
     }
 }
コード例 #4
0
 static string GetCarrierName()
 {
     using (var info = new CTTelephonyNetworkInfo())
     {
         return(info.SubscriberCellularProvider.CarrierName);
     }
 }
コード例 #5
0
        private bool CanDevicePlacePhoneCall(String pNumber)
        {
            if (UIApplication.SharedApplication.CanOpenUrl(new NSUrl(@"tel://" + pNumber)))
            {
                //A dialer is installed, now let's check if we can actually make a call.
                var networkInfo = new CTTelephonyNetworkInfo();
                var carrier     = networkInfo.SubscriberCellularProvider;
                if (carrier == null)
                {
                    App.MasterNavigation.DisplayAlert("Cannot make call", "No carrier", "Ok");
                    return(false);
                }
                var networkCode = carrier.MobileNetworkCode;
                if (String.IsNullOrEmpty(networkCode) || networkCode == "65535")
                {
                    //Device can not place a call
                    //SIM is probably inactive or not installed.
                    return(false);
                }
                else
                {
                    //Device most likely can make calls.
                    return(true);
                }
            }

            return(false);
        }
コード例 #6
0
        private long ParseNumberAsLong(string originalNumber)
        {
            string countryCode;

            CTTelephonyNetworkInfo info = new CTTelephonyNetworkInfo();
            CTCarrier carrier           = info.SubscriberCellularProvider;

            if (carrier != null)
            {
                countryCode = carrier.IsoCountryCode.ToUpper();
            }
            else
            {
                countryCode = "US";
            }

            PhoneNumberUtil util             = PhoneNumberUtil.GetInstance();
            PhoneNumber     number           = util.Parse(originalNumber, countryCode);
            string          normalizedNumber = util.Format(number, PhoneNumberFormat.E164);

            StringBuilder builder = new StringBuilder();

            foreach (char c in normalizedNumber)
            {
                if (char.IsDigit(c))
                {
                    builder.Append(c);
                }
            }
            return(long.Parse(builder.ToString()));
        }
        void InitializeComponents()
        {
            countriesViewController = new CountriesViewController();
            countriesViewController.CountrySelected += CountriesViewController_CountrySelected;

            var networkInfo = new CTTelephonyNetworkInfo();
            var carrier     = networkInfo.SubscriberCellularProvider;

            var countryCode = carrier.IsoCountryCode.ToUpper();
            var countryName = CountriesManager.SharedInstance.Countries [countryCode];
            var countryFlag = CountriesManager.SharedInstance.CountryFlags [countryCode];
            var phoneCode   = CountriesManager.SharedInstance.PhoneCodes [countryCode];

            phoneCode = phoneCode == string.Empty ? "" : $"+{phoneCode}";

            lblCountry = new StringElement($"{countryFlag} {countryName}", () => OpenViewController(countriesViewController))
            {
                Alignment = UITextAlignment.Center
            };
            txtPhoneNumber = new EntryElement(phoneCode, "Enter you phone number", string.Empty)
            {
                TextAlignment = UITextAlignment.Left,
                KeyboardType  = UIKeyboardType.PhonePad
            };
            btnVerify = new StyledStringElement("Send Verification Code", SendVerificationCode)
            {
                Alignment       = UITextAlignment.Center,
                Font            = UIFont.FromName("System-Bold", 13),
                BackgroundColor = UIColor.White
            };

            Root = new RootElement("Phone Number Authentication")
            {
                new Section("Tap to change the country")
                {
                    lblCountry,
                    txtPhoneNumber
                },
                new Section {
                    btnVerify
                }
            };

            indicatorView = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge)
            {
                Frame            = new CGRect(0, 0, 128, 128),
                BackgroundColor  = UIColor.FromRGBA(127, 127, 127, 127),
                HidesWhenStopped = true,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            View.Add(indicatorView);
            ApplyContraintsToIndicator();

            ShowInformationMessage();
        }
 /// <summary>
 /// If the mobile is connected to a mobile network then it will
 /// return the network technology being used.
 /// </summary>
 /// <returns></returns>
 public override string GetNetworkTechnology()
 {
     try
     {
         var networkInfo = new CTTelephonyNetworkInfo();
         return(networkInfo.CurrentRadioAccessTechnology);
     }
     catch
     {
         return("");
     }
 }
コード例 #9
0
        /// <summary>
        /// Loads the info.
        /// </summary>
        public void LoadInfo()
        {
            CTTelephonyNetworkInfo phoneNetworkInfo = new CTTelephonyNetworkInfo();

            CarrierName           = phoneNetworkInfo.SubscriberCellularProvider == null ? null : phoneNetworkInfo.SubscriberCellularProvider.CarrierName;
            CarrierName           = CarrierName ?? "Simulator";
            PhoneModel            = UIDevice.CurrentDevice.Model;
            PhonePlatform         = "ios";
            PhoneOS               = UIDevice.CurrentDevice.SystemVersion;
            AppVersion            = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString();
            HasSDCard             = DeviceHasSDCard();
            HasCarrierDataNetwork = IsCarrierDataNetworkOn();
        }
コード例 #10
0
ファイル: PhoneService.cs プロジェクト: ykoshimizu/Demo
        public void ShowUI(string dialNumber, string displayName)
        {
            var ctTelephonyNetworkInfo = new CTTelephonyNetworkInfo();
            var carrier = ctTelephonyNetworkInfo.SubscriberCellularProvider;

            if (carrier?.IsoCountryCode == null)
            {
                return;
            }

            var nsUrl  = new NSUrl(new System.Uri($"tel:{dialNumber}").AbsoluteUri);
            var result = UIApplication.SharedApplication.OpenUrl(nsUrl);
        }
 /// <summary>
 /// Returns the name of the service provider.
 /// </summary>
 /// <returns></returns>
 public override string GetCarrier()
 {
     try
     {
         var networkInfo = new CTTelephonyNetworkInfo();
         var carrier     = networkInfo.SubscriberCellularProvider;
         return(carrier.CarrierName);
     }
     catch
     {
         return("");
     }
 }
コード例 #12
0
        /// <summary>
        /// Gets the name of the phone service carrier.
        /// </summary>
        /// <returns>The phone service carrier name.</returns>
        string GetPhoneServiceCarrierName()
        {
            string carrierName = "N/A";

            using (var info = new CTTelephonyNetworkInfo())
            {
                if (info.SubscriberCellularProvider != null)
                {
                    carrierName = info.SubscriberCellularProvider.CarrierName;
                }
            }

            return(carrierName);
        }
コード例 #13
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			this.Title = "Core Telephony Info";
			this.TableView.AllowsSelection = false;
			this.TableView.DataSource = new TableViewDataSource (this);
			
			networkInfo = new CTTelephonyNetworkInfo ();
			callCenter = new CTCallCenter ();
			callCenter.CallEventHandler += CallEvent;
			carrierName = networkInfo.SubscriberCellularProvider == null ? null : networkInfo.SubscriberCellularProvider.CarrierName;
			networkInfo.CellularProviderUpdatedEventHandler += ProviderUpdatedEvent;
		}
コード例 #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.Title = "Core Telephony Info";
            this.TableView.AllowsSelection = false;
            this.TableView.DataSource      = new TableViewDataSource(this);

            networkInfo = new CTTelephonyNetworkInfo();
            callCenter  = new CTCallCenter();
            callCenter.CallEventHandler += CallEvent;
            carrierName = networkInfo.SubscriberCellularProvider == null ? null : networkInfo.SubscriberCellularProvider.CarrierName;
            networkInfo.CellularProviderUpdatedEventHandler += ProviderUpdatedEvent;
        }
コード例 #15
0
        public static void Call(this BaseController view, string tel)
        {
            var url = new NSUrl("tel:" + tel.Replace(" ", ""));

            if (UIApplication.SharedApplication.CanOpenUrl(url))
            {
                //A dialer is installed, now let's check if we can actually make a call.
                try
                {
                    var networkInfo = new CTTelephonyNetworkInfo();
                    var carrier     = networkInfo.SubscriberCellularProvider;
                    var networkCode = carrier.MobileNetworkCode;
                    if (string.IsNullOrEmpty(networkCode) || networkCode == "65535")
                    {
                        var av = UIAlertController.Create("Not supported",
                                                          "Dialing is not supported on this device",
                                                          UIAlertControllerStyle.Alert);
                        av.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));
                        view.PresentViewController(av, true, null);
                        Debug.WriteLine("Problem!");
                        //return false;
                    }
                    else
                    {
                        UIApplication.SharedApplication.OpenUrl(url);
                    }
                }
                catch (NullReferenceException)
                {
                    var av = UIAlertController.Create("Not supported",
                                                      "Dialing is not supported on this device",
                                                      UIAlertControllerStyle.Alert);
                    av.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));
                    view.PresentViewController(av, true, null);
                    Debug.WriteLine("Problem!");
                }
            }
        }
コード例 #16
0
        public string CountryCode()
        {
            var network_Info = new CTTelephonyNetworkInfo();
            var carrier      = network_Info.SubscriberCellularProvider;

            if (carrier != null)
            {
                try
                {
                    if (carrier.MobileCountryCode != null)
                    {
                        return(carrier.MobileCountryCode);
                    }
                }
                catch
                {
                    return(LocaleCountryCode());
                }
            }


            return(LocaleCountryCode());
        }
コード例 #17
0
        public void Init()
        {
            DeviceName = DeviceHardware.DeviceVersion;
            OS = "iOS";
            OSVersion = UIDevice.CurrentDevice.SystemVersion;
            var prov = new CTTelephonyNetworkInfo ().SubscriberCellularProvider;
            Carrier =  prov == null ? "Unknown" :  prov.CarrierName;
            UDID = GetUid ();

            var bounds = UIScreen.MainScreen.Bounds;
            var scale = UIScreen.MainScreen.Scale;
            bounds.Width *= scale;
            bounds.Height *=scale;
            Resulution = string.Format("{0}x{1}",bounds.Width,bounds.Height);

            Local = NSLocale.CurrentLocale.LocaleIdentifier;
            AppVersion = NSBundle.MainBundle.InfoDictionary.ObjectForKey(new NSString("CFBundleVersion")).ToString();

            Metrics = getMetrics ();
        }
コード例 #18
0
 public SimInformation(CTTelephonyNetworkInfo telephonyNetworkInfo = null)
 {
     _telephonyNetworkInfo = telephonyNetworkInfo ?? new CTTelephonyNetworkInfo();
 }