emcniece / cordova-plugin-rssi

Reports the WiFi RSSI for Android and iOS
MIT License
7 stars 3 forks source link

iOS 13 compatibility refactor #9

Closed emcniece closed 3 years ago

emcniece commented 3 years ago

This PR resolves https://github.com/emcniece/cordova-plugin-rssi/issues/8 with a caveat: RSSI is no longer available for iPhone X/XR/XS for iOS 11+, and for all other devices for iOS 13+. Instead these devices only return the number of bars visible in the wifi icon.

Prior to the implementation of the code in master branch it was thought that iPhone X devices had a unique element tree. Now it is apparent that iPhone X iOS 11-12 was a transition toward iOS 13, and all iOS 13+ devices use a compatible UIView tree. iPhone X for iOS 11-12 remains an edge case.

The getWifiBars() method is currently split into 2 blocks: the first for handling non-iPhone X/XR/XS (iOS 11-12), and the second for handling iPhone X/XR/XS. Neither block works on both groups. Ideally this can be executed with some logic to detect the UIView elements present and return bars for either device group.

An attempt to implement Mirror/reflection on the UIView objects failed. I hoped that by doing this the method could iterate over available view keys and conditionally handle the different devices. The two object extensions remain commented out at the top of this file in case this ends up being useful.

Todo:

emcniece commented 3 years ago

@msudol I think this is ready for testing. The iOS simulator successfully obtains bars for all versions and hardware platforms 🎉