如何在iPhone X上获得wifi强度

时间:2018-11-15 08:48:28

标签: ios xcode react-native wifi iphone-x

在stanadrd iPhone上,我正在使用以下代码:

 UIApplication *app = [UIApplication sharedApplication];
    NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
    NSString *dataNetworkItemView = nil;
    NSString *wifiNetworkItemView = nil;

    for (id subview in subviews) {
        if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarSignalStrengthItemView") class]]) {
            dataNetworkItemView = subview;
        }
        if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
            wifiNetworkItemView = subview;
        }
    }
    int wifiSignalStrength = [[wifiNetworkItemView valueForKey:@"wifiStrengthRaw"] intValue];

   // int carrierSignalStrength = [[dataNetworkItemView valueForKey:@"signalStrengthRaw"] intValue];

    NSString *strengthString = [NSString stringWithFormat:@"%d", wifiSignalStrength];

    callback(@[strengthString]);

但这不适用于iPhoneX。 有什么办法吗?似乎不存在。还是React Native中有一些解决方案?

0 个答案:

没有答案