2 Replies
      Latest reply: Nov 16, 2016 1:40 AM by eskimo RSS
      desarrollador.0001 Level 1 Level 1 (0 points)

        Hi,

         

        I know there are quite a few threads about this topic and I get that there is no way to do this without using private APIs but still, I'm in the need to ask it myself to get evidence for the company I work for.

         

        I'm building a speed test app (iOS with Swift) to try to meassure the quality of mobile and wifi internet services. One of my requirements is to display the signal strength of the phone's mobile network/wifi network.

        • Is there a way to measure or get signal strength from a wifi connection or a mobile connection?
        • Is there an iOS version in which this is or was allowed?
        • Is there any public API to get this information form?
        • Is there any way to get permission from Apple or some kind of entitlement to allow us to get it?
        • My boss found an app called OpenSignal that displays the signal strength of the mobile connection. That means there is a way to do it and get approved by the app store?

         

        I found that you can get the signal strength via StatusBar with this function:

            private func getSignal(isWifi:Bool) {
                var classNameForStatusBar = ""
                var valueForSignalValue = ""
                if(isWifi) {
                    classNameForStatusBar = "UIStatusBarDataNetworkItemView"
                    valueForSignalValue = "wifiStrengthBars"
                }
                else {
                    classNameForStatusBar = "UIStatusBarSignalStrengthItemView"
                    valueForSignalValue = "signalStrengthRaw"
                }
             
                let app = UIApplication.sharedApplication()
                let subViews = app.valueForKey("statusBar")?.valueForKey("foregroundView")?.subviews
                var dataNetworkItemView:UIView?
             
                if (subViews == nil) { return }
             
                for subview in subViews! {
                    if (subview.isKindOfClass(NSClassFromString(classNameForStatusBar)!)) {
                        dataNetworkItemView = subview;
                        break
                    }
                }
             
                let signal = dataNetworkItemView?.valueForKey(valueForSignalValue)
                print(signal)
            }
        
        

        On a similar thread (from June 2016), with a similar solution, an Apple staff member said it's not allowed (https://forums.developer.apple.com/message/141766#141766). Is it still the case?

         

        I would really appreciate any information or facts provided.

         

        Cheers.

        • Re: How to display internet signal strength inside my app
          KMT Level 8 Level 8 (9,910 points)

          Still the case.

           

          Your app can only verify a connection to the internet, it cannot sniff wi-fi/cell radio signal strength. That app your boss found is only pretending to know what it claims to know, BTW.

           

          Your statusbar method is an unauthorized hack and not something Apple allows discussion of on the forums, etc.

           

          Best to stick with the traditional speed test method and ping A to B.

          • Re: How to display internet signal strength inside my app
            eskimo Apple Staff Apple Staff (7,960 points)

            The answer varies by radio technology:

            • There is no supported way to get cellular signal strength.

            • There is no supported general-purpose way to get Wi-Fi signal strength.  Hotspot helper apps can do this (via NEHotspotNetwork’s signalStrength property) but only under very limited circumstances.

              IMPORTANT The primary technology here (NEHotspotHelper) was design to enable apps that help the user log on to a hotspot (that is, a Wi-Fi network that requires user interaction before granting access to the wider Internet).  NEHotspotHelper is not a general-purpose Wi-Fi management API, and that limitation is enforced at both the technical level and at the business level (it requires that you get special entitlements from Apple).

            • Core Bluetooth gives you easy access to the signal strength for Bluetooth LE devices (via -centralManager:didDiscoverPeripheral:advertisementData:RSSI:).

            The code you posted is not supported and is definitely grounds for App Review to reject your app.


            You need to consider the big picture here:

            • This is a commonly requested feature

            • It would not be too hard to implement (indeed, for things like NEHotspotHelper, Apple has done extra work to prevent general access to the facility)

            • We’re on iOS version 10

            • This API is still not available

            It’s not hard to join these dots and come to the conclusion that Apple does not want to provide signal strength APIs for cellular and Wi-Fi.  Any ‘clever’ hack you find to get this information is:

            • Not supported

            • Grounds for App Review rejection

            • Likely to be closed off as a security bug in a future OS release

            And, to head off the inevitable why question, AFAIK Apple has never published a formal explanation as to why it does not want to provide APIs for this, and in the absence of such formal guidance I’m not going to speculate.


            I’m sorry to be the bearer of bad news here but I hope that the above provides clarity for both you and your management.

            Share and Enjoy

            Quinn “The Eskimo!”
            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
            let myEmail = "eskimo" + "1" + "@apple.com"