Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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';

Expand Down
8 changes: 8 additions & 0 deletions src/ios/CDVConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ - (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
return @"4g";
// 5G available since iOS 14.1
} else if (@available(iOS 14.1, *)) {
if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNRNSA]) {
return @"5g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyNR]) {
return @"5g";
}
}
}
return @"cellular";
Expand All @@ -106,6 +113,7 @@ - (BOOL)isCellularConnection:(NSString*)theConnectionType
return [theConnectionType isEqualToString:@"2g"] ||
[theConnectionType isEqualToString:@"3g"] ||
[theConnectionType isEqualToString:@"4g"] ||
[theConnectionType isEqualToString:@"5g"] ||
[theConnectionType isEqualToString:@"cellular"];
}

Expand Down
2 changes: 2 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface Connection {
* Connection.CELL_2G
* Connection.CELL_3G
* Connection.CELL_4G
* Connection.CELL_5G
* Connection.CELL
* Connection.NONE
*/
Expand All @@ -57,6 +58,7 @@ declare var Connection: {
CELL_2G: string;
CELL_3G: string;
CELL_4G: string;
CELL_5G: string;
CELL: string;
NONE: string;
}
1 change: 1 addition & 0 deletions www/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
CELL_2G: '2g',
CELL_3G: '3g',
CELL_4G: '4g',
CELL_5G: '5g',
CELL: 'cellular',
NONE: 'none'
};