获取运营商名称时出现“–”。

huangapple go评论62阅读模式
英文:

Getting "--" when try to get carrier name

问题

I am trying to get the user carrier name using this code:

CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* carrier = info.subscriberCellularProvider;
NSString *mobileCountryCode = carrier.mobileCountryCode;
NSString *carrierName = carrier.carrierName;
NSString *isoCountryCode = carrier.isoCountryCode;
NSString *mobileNetworkCode = carrier.mobileNetworkCode;

But when I try to log, the result is like this:

2023-05-22 16:47:39.831078+0700 MotionTrade[7686:985518] carrier name = --
2023-05-22 16:47:39.831260+0700 MotionTrade[7686:985518] mobileCountryCode = 65535
2023-05-22 16:47:39.831342+0700 MotionTrade[7686:985518] mobileNetworkCode = 65535

Basically I've tried every stack overflow answer but I still get the same results,

I debug this on my iPhone and not using WiFi, and I only use physical sim, not e-sim.

Can anyone tell me why I keep getting that "--"?

And after I browse a bit, country code "65535" is this could be an indication of removed SIM card, or in general inability to make a call at the moment.

Can anyone help me? Why is this happening and how to get a proper cellular provider name?

I even try to do it on my new blank project with this code:

override func viewDidLoad() {
super.viewDidLoad()

let networkInfo = CTTelephonyNetworkInfo()
let carrierName = networkInfo.serviceSubscriberCellularProviders

dump(carrierName)
}

but I still get the same result in my log:

Optional(["0000000100000001": CTCarrier (0x281275d10) {
Carrier name: [--]
Mobile Country Code: [65535]
Mobile Network Code:[65535]
ISO Country Code:[--]
Allows VOIP? [YES]
}
, "0000000100000002": CTCarrier (0x28126ca20) {
Carrier name: [--]
Mobile Country Code: [65535]
Mobile Network Code:[65535]
ISO Country Code:[--]
Allows VOIP? [YES]
}
] )

Please help me. Why do I keep getting "--" and 65535? Is there any way to get carrier name? Or is getting carrier name in iOS 16 not possible?

英文:

I am trying to get the user carrier name using this code:

CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* carrier = info.subscriberCellularProvider;
NSString *mobileCountryCode = carrier.mobileCountryCode;
NSString *carrierName = carrier.carrierName;
NSString *isoCountryCode = carrier.isoCountryCode;
NSString *mobileNetworkCode = carrier.mobileNetworkCode;

But when I try to log, the result is like this:

2023-05-22 16:47:39.831078+0700 MotionTrade[7686:985518] carrier name = --
2023-05-22 16:47:39.831260+0700 MotionTrade[7686:985518] mobileCountryCode = 65535
2023-05-22 16:47:39.831342+0700 MotionTrade[7686:985518] mobileNetworkCode = 65535

Basically I've tried every stack overflow answer but I still get the same results,

I debug this on my iPhone and not using WiFi, and I only use physical sim, not e-sim.

Can anyone tell me why I keep getting that "--"?

And after I browse a bit, country code "65535" is this could be an indication of removed SIM card, or in general inability to make a call at the moment.

Can anyone help me? Why is this happening and how to get a proper cellular provider name?

I even try to do it on my new blank project with this code:

override func viewDidLoad() {
    super.viewDidLoad()

    let networkInfo = CTTelephonyNetworkInfo()
    let carrierName = networkInfo.serviceSubscriberCellularProviders
    
    dump(carrierName)
}

but I still get the same result in my log:

Optional(["0000000100000001": CTCarrier (0x281275d10) {
Carrier name: [--]
Mobile Country Code: [65535]
Mobile Network Code:[65535]
ISO Country Code:[--]
Allows VOIP? [YES]
}
, "0000000100000002": CTCarrier (0x28126ca20) {
Carrier name: [--]
Mobile Country Code: [65535]
Mobile Network Code:[65535]
ISO Country Code:[--]
Allows VOIP? [YES]
 }
  ]    )

Please help me. Why do I keep getting "--" and 65535? Is there any way to get carrier name? Or is getting carrier name in iOS 16 not possible?

答案1

得分: 1

[CTCarrier is deprecated with no replacement in iOS 16.](https://developer.apple.com/forums/thread/714876) 此信息已在iOS 16中取消,并且我不指望会再次提供。我对它曾经可用感到有些惊讶。(苹果通常避免提供可用于用户指纹识别的信息,除非有非常明确的用例和通常是一个权利。)

您可以在[iOS 16.4 发布说明](https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16_4-release-notes#Core-Telephony)中找到有关返回静态值的公告。

英文:

CTCarrier is deprecated with no replacement in iOS 16. This information is no longer available, and I would not expect it to become available again. I'm somewhat surprised it was ever available. (Apple generally avoids making information available that can be used to fingerprint the user without a very clear use case, and usually an entitlement.)

You can find the announcement about returning static values in the iOS 16.4 Release Notes.

huangapple
  • 本文由 发表于 2023年5月22日 18:07:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76305070.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定