Fix network plugin for ios14+ (#1543)

Summary:
Changelog: [iOS][Network] Network plugin now supports iOS 14

Network plugin stopped working for iOS 14 as reported in https://github.com/facebook/flipper/issues/1534.
The fix is based on the origin Flex network observer, as seen in https://github.com/FLEXTool/FLEX/pull/451

- NetworkPlugin supports iOS 14+

Pull Request resolved: https://github.com/facebook/flipper/pull/1543

Test Plan: Verified manually that before this fix the network plugin broken on iOS 14, and after it, it initializes correctly.

Reviewed By: passy

Differential Revision: D24136401

Pulled By: mweststrate

fbshipit-source-id: 87e0e0fa4bc927d082387d937390b1e728125753
This commit is contained in:
Christos Botsikas
2020-10-06 11:19:56 -07:00
committed by Facebook GitHub Bot
parent f9fbca80e7
commit 86e48b2140

View File

@@ -318,6 +318,7 @@ typedef void (^NSURLSessionAsyncCompletion)(
// In iOS 7 resume lives in __NSCFLocalSessionTask
// In iOS 8 resume lives in NSURLSessionTask
// In iOS 9 resume lives in __NSCFURLSessionTask
// In iOS 14 resume lives in NSURLSessionTask
Class className = Nil;
if (![[NSProcessInfo processInfo]
respondsToSelector:@selector(operatingSystemVersion)]) {
@@ -325,7 +326,8 @@ typedef void (^NSURLSessionAsyncCompletion)(
NSClassFromString([@[ @"__", @"NSC", @"FLocalS", @"ession", @"Task" ]
componentsJoinedByString:@""]);
} else if (
[[NSProcessInfo processInfo] operatingSystemVersion].majorVersion < 9) {
[[NSProcessInfo processInfo] operatingSystemVersion].majorVersion < 9 ||
[[NSProcessInfo processInfo] operatingSystemVersion].majorVersion >= 14) {
className = [NSURLSessionTask class];
} else {
className =