Question

In my application i want to get the mobile network signal strength and network providers name, in the below code it is returning the signal strength but i'm not feeling it as accurate ,because when the strength value went to 60% also the signal sticks are showing full.and the network provider name is returned as carrier.i'm calling this method for every 2 seconds.

-(void)UpdateLabelWithSignal{
   int str = CTGetSignalStrength();
   NSLog(@"SignalStrength:%d",str);
   NSLog(@"SignalStrength:%@",[NSString stringWithFormat:@"%d",str]);
   SignalLabel.text = [NSString stringWithFormat:@"%d",str];

}

//code for getting network provider name

    CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
    CTCarrier *carrier = [netinfo subscriberCellularProvider];
    NSLog(@"MY NAME:%@",carrier.carrierName);   
Was it helpful?

Solution

if you want it accurately update it for every few seconds.here is the code.

 - (void)viewDidLoad
 {
  [super viewDidLoad];

  printf("signal strength: %d\n", CTGetSignalStrength());
 slimeDeathAnimTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(UpdateLabelWithSignal) userInfo:nil repeats:YES];
  CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init];
  CTCarrier *carrier = [netinfo subscriberCellularProvider];
  NSLog(@"MY NAME:%@",carrier.carrierName);

  NSLog(@"mobileCountryCode = %@",carrier.mobileCountryCode);
  NSLog(@"mobileNetworkCode = %@",carrier.mobileNetworkCode);
  NSLog(@"isoCountryCode = %@",carrier.isoCountryCode);
  NSLog(@"allowVOIP = %d",carrier.allowsVOIP);

  }

-(void)UpdateLabelWithSignal{

int str = CTGetSignalStrength();
NSLog(@"SignalStrength:%d",str);
  NSLog(@"SignalStrength:%@",[NSString stringWithFormat:@"%d",str]);
SignalLabel.text = [NSString stringWithFormat:@"%d",str];

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top