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

getMobileCarrierName spams logs due to call to non-functional serviceSubscriberCellularProviders #1055

Open
3 tasks done
rnapier opened this issue Jul 5, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@rnapier
Copy link

rnapier commented Jul 5, 2024

Prerequisites

  • This is not a Security Disclosure, otherwise please follow the guidelines in Security Policy.
  • I have searched in this repository's issues to see if it has already been reported.
  • I have updated to the latest released version of the SDK and the issue still persists.

Bug summary

Since iOS 16, it is no longer possible to get the mobile carrier information. The required functions are deprecated without replacement, and the OS will return a stub response with name "--" on device and nil on simulator. This is slow and spams the logs with errors such as:

2024-07-04 14:02:52.249495-0400 ...[56386:3273558] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated: failed at lookup with error 3 - No such process.}

This call should be avoided on iOS 16+.

Environment

OS: iOS 16+
SDK: AEP 5.2.0
IDE: Xcode 15.4

Steps to reproduce

Call getMobileCarrierName. Observe logs for com.apple.commcenter.coretelephony.xpc errors.

Current behavior

Spams logs with errors and returns "--" or nil.

Expected behavior

Should not attempt to access CoreTelephony on iOS 16+.

Anything else?

Something like the following would address the problem:

diff --git a/AEPServices/Sources/ApplicationSystemInfoService.swift b/AEPServices/Sources/ApplicationSystemInfoService.swift
index fbaa615..9bcaeae 100644
--- a/AEPServices/Sources/ApplicationSystemInfoService.swift
+++ b/AEPServices/Sources/ApplicationSystemInfoService.swift
@@ -106,6 +106,11 @@ class ApplicationSystemInfoService: SystemInfoService {
         #if targetEnvironment(macCatalyst) || os(tvOS)
             return "unknown"
         #else
+        if #available(iOS 16, *) {
+            // Since iOS 16, `serviceSubscriberCellularProviders` is deprecated without replacement.
+            // `carrierName` always returns "--" and may throw errors into the logs.
+            return "--"
+        } else {
             let networkInfo = CTTelephonyNetworkInfo()
             let carrier: CTCarrier?
             if #available(iOS 12, *) {
@@ -115,6 +120,7 @@ class ApplicationSystemInfoService: SystemInfoService {
             }

             return carrier?.carrierName
+        }
         #endif
     }
@rnapier rnapier added bug Something isn't working. Used by issue templates triage-required Triage required on a new issue logged for this project. Used by issue templates labels Jul 5, 2024
@praveek praveek removed the triage-required Triage required on a new issue logged for this project. Used by issue templates label Jul 12, 2024
@cdhoffmann
Copy link
Contributor

@rnapier Thanks for reporting this. We will be marking this as an enhancement because we have to discuss with the team if using an availability macro is sufficient of if we should look at a more robust e2e approach to this. Will keep you posted on the ticket once we pick it up.

@cdhoffmann cdhoffmann added enhancement New feature or request and removed bug Something isn't working. Used by issue templates labels Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants