title: Socket Mobile Battery Level iOS
body: <p>I am using a Socket Mobile barcode scanner (Socket 7Xi) in my app. I have integrated the SDK from Socket Mobile (ScanApiSDK-10.2.227) and setup the scanner for iOS mode. My application receives barcodes as expected. However, the device seems to get a little cranky when the battery level is low (I think). I would like to display the battery level in the application, so I can remind users to plug the socket scanner in, and generally debug scanning issues.</p>
  
  <p>I am using the following call to get the battery level:</p>
  
  <pre><code>[_scanApiHelper postGetBattery:_deviceInfo Target:self Response:@selector(onGetBattery:)];
  </code></pre>
  
  <p>Which gets returned in the following method:</p>
  
  <pre><code>-(void)onGetBattery:(ISktScanObject*)obj{
      ISktScanProperty* property = [obj Property];
      if (property){
  
          unsigned char level = SKTBATTERY_GETCURLEVEL([property getUlong]);
          unsigned char minLevel = SKTBATTERY_GETMINLEVEL([property getUlong]);
          unsigned char maxLevel = SKTBATTERY_GETMAXLEVEL([property getUlong]);
  
          float levelf = level;
          float minLevelf = minLevel;
          float maxLevelf = maxLevel;
  
          float percentf = (levelf-minLevelf)/(maxLevelf-minLevelf)*100;
  
          NSLog(@"percent: %f", percentf);
      }
  }
  </code></pre>
  
  <p>The onGetBattery method gets called, but the ulong I get back is 1677747200, which after calling the utility methods gives me a level=64, minLevel=0, maxLevel=64. Which should be interpreted as 100% (percentf = 100.00).</p>
  
  <p>However, it seems to always return this value. Never anything less than fully charged. </p>
  
  <p>I also tried the getBatteyLevel method on DeviceInfo, but that just returns nil.</p>
  
  <p>How do I get the current battery level for my device?</p>
  
  <p>Thanks!</p>