CoreTelephony SubscriberInfo returns nil values when called from Unwanted Communication Extension

Everywhere I can find the same solution to retrieve carrier information. So Im sure it works. but, For me its returning an error:

Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099
 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated."
 UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc
 was invalidated.}


The code that generates this error is inside unwanted message communication extension like:

let networkInfo = CTTelephonyNetworkInfo()
let carrier = networkInfo.subscriberCellularProvider
print(carrier);

As it works in the parent app but not inside the target extension, Im sure that the Extension is not allowing me to do so. If thats the case then what are my other options? It would be a roadblock if I cannot send the Carrier Name of the user along with the userInfo.

Answered by DTS Engineer in 326750022

I’m not familiar with Unwanted Communication app extensions, so I’m going to respond in a very general sense. It’s possible that there are aspects of this that are specific to Unwanted Communication app extensions that I’m not aware of )-:

It’s not uncommon for app extensions to run in a tighter sandbox than normal app and I suspect that’s what’s happening here: Your app runs in the standard sandbox, and thus can talk to the backend service used by

CTTelephonyNetworkInfo
, but your app extension is running in a tighter sandbox that prevents that.

If that theory is correct then you won’t be able to work around it directly. One possibility indirect solution is to have your app get that info and store it in an app group shared container that it shares with the app extension. The app extension can then read that info and include it with its requests.

However, it’s possible that the app extension sandbox also prevents read access to shared app groups. That would be pretty unusual, but it’s technically possible and might even make sense given the privacy-sensitive nature of an Unwanted Communication app extension.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Accepted Answer

I’m not familiar with Unwanted Communication app extensions, so I’m going to respond in a very general sense. It’s possible that there are aspects of this that are specific to Unwanted Communication app extensions that I’m not aware of )-:

It’s not uncommon for app extensions to run in a tighter sandbox than normal app and I suspect that’s what’s happening here: Your app runs in the standard sandbox, and thus can talk to the backend service used by

CTTelephonyNetworkInfo
, but your app extension is running in a tighter sandbox that prevents that.

If that theory is correct then you won’t be able to work around it directly. One possibility indirect solution is to have your app get that info and store it in an app group shared container that it shares with the app extension. The app extension can then read that info and include it with its requests.

However, it’s possible that the app extension sandbox also prevents read access to shared app groups. That would be pretty unusual, but it’s technically possible and might even make sense given the privacy-sensitive nature of an Unwanted Communication app extension.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

That is exactly how I ended up doing it.. one caveat is that I have to open my app atleast once before it can write to shared UserDefault

one caveat is that I have to open my app atleast once before it can write to shared UserDefault

Indeed. If you want to get around that, my recommendation is that you file a bug against requesting that Unwanted Communication app extensions have better access to this info.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
CoreTelephony SubscriberInfo returns nil values when called from Unwanted Communication Extension
 
 
Q