You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "GitToTheHub (via GitHub)" <gi...@apache.org> on 2026/03/26 17:02:49 UTC

[PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

GitToTheHub opened a new pull request, #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169

   <!--
   Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:
   
   http://cordova.apache.org/contribute/contribute_guidelines.html
   
   Thanks!
   -->
   
   ### Platforms affected
   iOS
   
   ### Motivation and Context
   <!-- Why is this change required? What problem does it solve? -->
   <!-- If it fixes an open issue, please link to the issue here. -->
   - Fixes all deprecation warnings with XCode 26.4 and cordova-ios 8
   
   
   ### Description
   <!-- Describe your changes in detail -->
   - `currentRadioAccessTechnology` is deprecated since iOS 12: https://developer.apple.com/documentation/coretelephony/cttelephonynetworkinfo/currentradioaccesstechnology?language=objc, instead `serviceCurrentRadioAccessTechnology` should be used.
   - Add method `currentRadioAccessTechnology` which uses `serviceCurrentRadioAccessTechnology` on iOS 12 and newer and `currentRadioAccessTechnology` on iOS 11 and older
   - `CTRadioAccessTechnologyDidChangeNotification` is deprecated since iOS 12: https://developer.apple.com/documentation/coretelephony/ctradioaccesstechnologydidchangenotification?language=objc. Instead `CTServiceRadioAccessTechnologyDidChangeNotification` should be used.
   
   
   ### Testing
   <!-- Please describe in detail how you tested your changes. -->
   - Tested with the Hello World app and XCode 26.4
   
   
   ### Checklist
   
   - [ ] I've run the tests to see all new and existing tests pass
   - [ ] I added automated test coverage as appropriate for this change
   - [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
   - [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
   - [ ] I've updated the documentation if necessary
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub merged PR #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on code in PR #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169#discussion_r3015408764


##########
src/ios/CDVConnection.m:
##########
@@ -101,6 +101,20 @@ - (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
     }
 }
 
+- (NSString*)currentRadioAccessTechnology
+{
+    CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];

Review Comment:
   Won't fix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169#issuecomment-4162455424

   > Once a patch is released, I think we should consider doing a major bump to then clean up some of the code, requiring cordova-ios@8, which is a min iOS 13 support... we can then clean up some of the backwards compatibility stuff.
   >
   > Not sure if there any anything worth cleaning on the android side, but a 4.x target would be the time to do it.
   
   Yes this sounds good.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169#issuecomment-4162094725

   If evertyhing ok with this? I would like to merge it and start to make a release to make this plugin work again with XCode 26.4


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169#discussion_r2996417882


##########
src/ios/CDVConnection.m:
##########
@@ -101,6 +101,20 @@ - (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
     }
 }
 
+- (NSString*)currentRadioAccessTechnology
+{
+    CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];

Review Comment:
   New private method `-currentRadioAccessTechnology` isn’t declared in the existing `CDVConnection (PrivateMethods)` category at the top of the file. Declaring it there keeps private API consistent with the file’s pattern and avoids potential missing-prototype / signature checking issues.



##########
src/ios/CDVConnection.m:
##########
@@ -101,6 +101,20 @@ - (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
     }
 }
 
+- (NSString*)currentRadioAccessTechnology
+{
+    CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
+
+    if (@available(iOS 12.0, *)) {
+        return telephonyInfo.serviceCurrentRadioAccessTechnology.allValues.firstObject;

Review Comment:
   `serviceCurrentRadioAccessTechnology` is a dictionary (multi‑SIM). Using `allValues.firstObject` is non-deterministic and can report the wrong RAT when multiple services exist. Prefer selecting the RAT for the active data service (e.g., via `dataServiceIdentifier` when available) and fall back deterministically when it’s not.
   ```suggestion
           NSDictionary<NSString*, NSString*> *ratByService = telephonyInfo.serviceCurrentRadioAccessTechnology;
           if (ratByService.count == 0) {
               return nil;
           }
   
           NSString *currentRAT = nil;
   
   #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
           if (@available(iOS 13.0, *)) {
               NSString *dataServiceIdentifier = telephonyInfo.dataServiceIdentifier;
               if (dataServiceIdentifier.length > 0) {
                   currentRAT = ratByService[dataServiceIdentifier];
               }
           }
   #endif
   
           if (!currentRAT) {
               NSArray<NSString*> *sortedKeys = [[ratByService allKeys] sortedArrayUsingSelector:@selector(compare:)];
               NSString *firstKey = sortedKeys.firstObject;
               currentRAT = firstKey != nil ? ratByService[firstKey] : nil;
           }
   
           return currentRAT;
   ```



##########
src/ios/CDVConnection.m:
##########
@@ -151,8 +165,16 @@ - (void)pluginInitialize
     [self.internetReach startNotifier];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
                                                  name:kReachabilityChangedNotification object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
-                                                 name:CTRadioAccessTechnologyDidChangeNotification object:nil];
+    if (@available(iOS 12.0, *)) {
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
+                                                     name:CTServiceRadioAccessTechnologyDidChangeNotification object:nil];
+    } else {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
+                                                     name:CTRadioAccessTechnologyDidChangeNotification object:nil];
+#pragma clang diagnostic pop

Review Comment:
   The telephony notification observers call `updateConnectionType:`, but that handler only updates when `note.object` is a `CDVReachability` instance. CoreTelephony change notifications don’t provide a `CDVReachability` object, so these observers won’t refresh `connectionType`. Consider adding a dedicated handler for radio tech changes (or make `updateConnectionType:` fall back to updating using `self.internetReach`).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on code in PR #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169#discussion_r3015394560


##########
src/ios/CDVConnection.m:
##########
@@ -151,8 +165,16 @@ - (void)pluginInitialize
     [self.internetReach startNotifier];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
                                                  name:kReachabilityChangedNotification object:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
-                                                 name:CTRadioAccessTechnologyDidChangeNotification object:nil];
+    if (@available(iOS 12.0, *)) {
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
+                                                     name:CTServiceRadioAccessTechnologyDidChangeNotification object:nil];
+    } else {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
+                                                     name:CTRadioAccessTechnologyDidChangeNotification object:nil];
+#pragma clang diagnostic pop

Review Comment:
   Won't fix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169#issuecomment-4162181752

   I merged the 5G change into it and adjusted it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix(ios): fix deprecation warnings for iOS 12+ [cordova-plugin-network-information]

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #169:
URL: https://github.com/apache/cordova-plugin-network-information/pull/169#issuecomment-4162444735

   > If evertyhing ok with this? I would like to merge it and start to make a release to make this plugin work again with XCode 26.4
   
   Yah I think this repo has a lot of fixes that have been sitting in master that should be pushed to an actual release.
   
   Once a patch is released, I think we should consider doing a major bump to then clean up some of the code, requiring cordova-ios@8, which is a min iOS 13 support... we can then clean up some of the backwards compatibility stuff.
   
   Not sure if there any anything worth cleaning on the android side, but a 4.x target would be the time to do it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org