Hallo!
In Xcode benutze ich folgende Code, um Informationen über den aktuellen Mobilfunkprovider abzufragen:
Code:
#import <CoreTelephony/CTTelephonynetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
...
...
CTCarrier *provider [[[CTTelephonyNetworkInfo alloc] init] subscriberCellularProvider];
if(provider != nil) {
NSString *providerName = [NSString stringWithString:[provider carrierName]];
NSString *providerIsoCountryCode = [NSString stringWithString:[provider isoCountryCode]];
//etc.
}
Wenn ich nun versuche, die Code in Delphi zu implementieren, bleibt
provider ohne Wert. Hier meine Code:
Delphi-Quellcode:
uses
..., iOSApi.Foundation, iOSApi.UIKit, iOSApi.CocoaTypes, iOSApi.CoreTelephony;
...
procedure TiOSTelephony.UpdateProviderInfo;
var
networkInfo: CTTelephonyNetworkInfo;
provider: CTCarrier;
begin
try
networkInfo := TCTTelephonyNetworkInfo.Wrap(TCTTelephonyNetworkInfo.OCClass.alloc);
provider := networkInfo.subscriberCellularProvider;
if Assigned(provider) then
begin
FProviderName := NSStringToString(provider.carrierName);
FProviderISOCountryCode := NSStringToString(provider.isoCountryCode);
FProviderMobileCountryCode := NSStringToString(provider.mobileCountryCode);
FProviderMobileNetworkCode := NSStringToString(provider.mobileNetworkCode);
FProviderAllowsVOIP := provider.allowsVOIP;
end;
except
end;
Was mache ich falsch?