diff --git a/README.md b/README.md index e5ce592..914c502 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ wifi connection, and whether the device has an internet connection. - Connection.CELL_2G - Connection.CELL_3G - Connection.CELL_4G +- Connection.CELL_5G - Connection.CELL - Connection.NONE @@ -81,6 +82,7 @@ function checkConnection() { states[Connection.CELL_2G] = 'Cell 2G connection'; states[Connection.CELL_3G] = 'Cell 3G connection'; states[Connection.CELL_4G] = 'Cell 4G connection'; + states[Connection.CELL_5G] = 'Cell 5G connection'; states[Connection.CELL] = 'Cell generic connection'; states[Connection.NONE] = 'No network connection'; diff --git a/src/ios/CDVConnection.m b/src/ios/CDVConnection.m index 40b2e42..f7c254f 100644 --- a/src/ios/CDVConnection.m +++ b/src/ios/CDVConnection.m @@ -83,6 +83,14 @@ - (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) { return @"4g"; } + + if (@available(iOS 14.1, *)) { + if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA]) { + return @"5g"; + } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR]) { + return @"5g"; + } + } } return @"cellular"; } @@ -106,6 +114,7 @@ - (BOOL)isCellularConnection:(NSString*)theConnectionType return [theConnectionType isEqualToString:@"2g"] || [theConnectionType isEqualToString:@"3g"] || [theConnectionType isEqualToString:@"4g"] || + [theConnectionType isEqualToString:@"5g"] || [theConnectionType isEqualToString:@"cellular"]; } diff --git a/types/index.d.ts b/types/index.d.ts index 60b6c26..77e68b6 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -42,6 +42,7 @@ interface Connection { * Connection.CELL_2G * Connection.CELL_3G * Connection.CELL_4G + * Connection.CELL_5G * Connection.CELL * Connection.NONE */ @@ -57,6 +58,7 @@ declare var Connection: { CELL_2G: string; CELL_3G: string; CELL_4G: string; + CELL_5G: string; CELL: string; NONE: string; } \ No newline at end of file diff --git a/www/Connection.js b/www/Connection.js index fb1d0ad..962908e 100644 --- a/www/Connection.js +++ b/www/Connection.js @@ -29,6 +29,7 @@ module.exports = { CELL_2G: '2g', CELL_3G: '3g', CELL_4G: '4g', + CELL_5G: '5g', CELL: 'cellular', NONE: 'none' };