Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(iOS) Check 5G network in iOS platform #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions src/ios/CDVConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -106,6 +114,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'
};