user2402997
user2402997

Reputation: 107

How to find accurate mobile signal strength and Service Provider Name?

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);   

Upvotes: 2

Views: 985

Answers (1)

KMKR
KMKR

Reputation: 109

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];

}

Upvotes: 1

Related Questions