Device identifier by Airbridge. (example: 82A16EC9-A273-48B6-9BB2-017EAB641109)
import Airbridge
Airbridge.fetchDeviceUUID { deviceUUID in
}
#import <Airbridge/Airbridge.h>
[Airbridge fetchDeviceUUID:^(NSString * _Nonnull deviceUUID) {
}];
import AirBridge
AirBridge.deviceUUID
#import <AirBridge/AirBridge.h>
AirBridge.deviceUUID;
Random UUID assigned by Airbridge upon app install on each device. (example: 82A16EC9-A273-48B6-9BB2-017EAB641109)
import Airbridge
Airbridge.fetchAirbridgeGeneratedUUID { airbridgeGeneratedUUID in
}
#import <Airbridge/Airbridge.h>
[Airbridge fetchAirbridgeGeneratedUUID:^(NSString * _Nonnull airbridgeGeneratedUUID) {
}];
import AirBridge
AirBridge.fetchAirbridgeGeneratedUUID { uuid in
}
#import <AirBridge/AirBridge.h>
[AirBridge fetchAirbridgeGeneratedUUID:^(NSString * _Nonnull uuid) {
}];
Advertising ID issued by Apple. (example: 82A16EC9-A273-48B6-9BB2-017EAB641109)
import AdSupport
ASIdentifierManager.shared().advertisingIdentifier.uuidString
#import <AdSupport/AdSupport.h>
ASIdentifierManager.sharedManager.advertisingIdentifier.UUIDString;
Unique ID that publishers can use to identify which apps a specific user has installed. (example: 82A16EC9-A273-48B6-9BB2-017EAB641109)
UIDevice.current.identifierForVendor?.uuidString
UIDevice.currentDevice.identifierForVendor.UUIDString;
Device's Limit AD Tracking information. (example: true)
import AdSupport
ASIdentifierManager.shared().isAdvertisingTrackingEnabled
#import <AdSupport/AdSupport.h>
ASIdentifierManager.sharedManager.advertisingTrackingEnabled;
Device model name. (example: iPhone)
UIDevice.current.localizedModel
UIDevice.currentDevice.localizedModel;
Device identifier name. (example: iPhone9,3)
var systemInfo = utsname()
uname(&systemInfo)
return String(cString: &systemInfo.machine.0, encoding: .utf8)
#import <sys/utsname.h>
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
Device manufacturer information. (example: Apple)
"Apple"
@"Apple"
Device OS name. (example: iOS)
UIDevice.current.systemName
UIDevice.currentDevice.systemName;
Device OS version. (example: 13.3)
UIDevice.current.systemVersion
UIDevice.currentDevice.systemVersion;
Device locale settings. (example: ko-KR)
func getSystemLocale() -> String? {
guard let language = getSystemLanguage() else { return nil }
guard let country = getSystemCountry() else { return nil }
return "\(language)-\(country)"
}
func getSystemLanguage() -> String? {
let languages = Locale.preferredLanguages
if languages.count < 1 {
return nil
}
let languageSource = languages[0]
guard let barIndex = languageSource.range(of: "-") else {
return languageSource
}
return String(languageSource[..<barIndex.lowerBound])
}
func getSystemCountry() -> String? {
return Locale.autoupdatingCurrent.regionCode
}
+ (NSString *)getSystemLocale {
NSString* language = [#ClassName# getSystemLanguage];
NSString* country = [#ClassName# getSystemCountry];
if(language == nil || country == nil) {
return nil;
}
return [NSString stringWithFormat:@"%@-%@", language, country];
}
+ (NSString*) getSystemLanguage {
NSArray* preferredLanguages = NSLocale.preferredLanguages;
if (preferredLanguages.count < 1) {
return nil;
}
NSString* languageSource = preferredLanguages[0];
if (languageSource == nil) {
return nil;
}
NSRange barIndex = [languageSource rangeOfString:@"-"];
if (barIndex.location != NSNotFound) {
languageSource = [languageSource substringToIndex:barIndex.location];
}
return languageSource;
}
+ (NSString*) getSystemCountry {
NSLocale* locale = NSLocale.autoupdatingCurrentLocale;
if (locale == nil) {
return nil;
}
return [locale objectForKey:NSLocaleCountryCode];
}
Device timezone settings. (example: US/Pacific)
TimeZone.current.description
NSTimeZone.systemTimeZone.name;
Device display orientation. Values will be either "portrait" or "landscape". (example: portrait)
if UIDevice.current.orientation.isLandscape {
return @"landscape"
} else {
return @"portrait"
}
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation))
return @"landscape";
else
return @"portrait";
Device's screen density. (example: 3.000)
String(format: "%.3f", UIScreen.main.scale)
[NSString stringWithFormat:@"%.3f", UIScreen.mainScreen.scale];
Device's actual width. (example: 375.0)
String(format: "%.f", UIScreen.main.bounds.size.width)
[NSString stringWithFormat:@"%.f", UIScreen.mainScreen.bounds.size.width];
Device's actual height. (example: 667.0)
String(format: "%.f", UIScreen.main.bounds.size.height)
[NSString stringWithFormat:@"%.f", UIScreen.mainScreen.bounds.size.height];
Device network carrier information.
import CoreTelephony
let info = CTTelephonyNetworkInfo()
if #available(iOS 12.1, *) {
let providers = info.serviceSubscriberCellularProviders
return providers?.values.first?.carrierName
} else {
let provider = info.subscriberCellularProvider
return provider?.carrierName
}
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
CTTelephonyNetworkInfo* networkInfo = [[CTTelephonyNetworkInfo alloc] init];
if (@available(iOS 12.1, *)) {
NSDictionary<NSString*, CTCarrier*>* providers = [networkInfo serviceSubscriberCellularProviders];
return providers.allValues.firstObject.carrierName;
} else {
CTCarrier* provider = [networkInfo subscriberCellularProvider];
return provider.carrierName;
}
Device mobile data status. (example: true)
import SystemConfiguration
func isCellular() -> Bool {
return network() == .cellular
}
enum Network {
case wifi
case cellular
case none
}
func getNetworkInfo() -> Network {
var zeroAddress = sockaddr()
bzero(&zeroAddress, MemoryLayout.size(ofValue: zeroAddress))
zeroAddress.sa_len = __uint8_t(MemoryLayout.size(ofValue: zeroAddress))
zeroAddress.sa_family = sa_family_t(AF_INET)
guard let reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, &zeroAddress) else {
return .none
}
var flags = SCNetworkReachabilityFlags()
if !SCNetworkReachabilityGetFlags(reachability, &flags) {
return .none
}
if !flags.contains(.reachable) {
return .none
}
if flags.contains(.connectionRequired)
&& !((flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic))
&& !flags.contains(.interventionRequired)) {
return .none
}
if flags.contains(.isWWAN) {
return .cellular
} else {
return .wifi
}
}
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>
+ (BOOL) isCellular {
return [#ClassName# getNetworkInfo] == CELLULAR;
}
typedef enum : NSInteger {
WIFI,
CELLULAR,
NONE
} ABNetwork;
+ (ABNetwork) getNetworkInfo {
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;
SCNetworkReachabilityRef reachability
= SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *) &zeroAddress);
if (reachability == nil) {
return NONE;
}
SCNetworkReachabilityFlags flags;
if (!SCNetworkReachabilityGetFlags(reachability, &flags)) {
return NONE;
}
if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
return NONE;
}
if (((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0)
&& !(((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0 || (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)
&& (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0))
{
return NONE;
}
if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
return CELLULAR;
} else {
return WIFI;
}
}
Device wifi status. (example: true)
import SystemConfiguration
func isWifi() -> Bool {
return network() == .wifi
}
enum Network {
case wifi
case cellular
case none
}
func getNetworkInfo() -> Network {
var zeroAddress = sockaddr()
bzero(&zeroAddress, MemoryLayout.size(ofValue: zeroAddress))
zeroAddress.sa_len = __uint8_t(MemoryLayout.size(ofValue: zeroAddress))
zeroAddress.sa_family = sa_family_t(AF_INET)
guard let reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, &zeroAddress) else {
return .none
}
var flags = SCNetworkReachabilityFlags()
if !SCNetworkReachabilityGetFlags(reachability, &flags) {
return .none
}
if !flags.contains(.reachable) {
return .none
}
if flags.contains(.connectionRequired)
&& !((flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic))
&& !flags.contains(.interventionRequired)) {
return .none
}
if flags.contains(.isWWAN) {
return .cellular
} else {
return .wifi
}
}
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>
+ (BOOL) isWifi {
return [#ClassName# getNetworkInfo] == WIFI;
}
typedef enum : NSInteger {
WIFI,
CELLULAR,
NONE
} ABNetwork;
+ (ABNetwork) getNetworkInfo {
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;
SCNetworkReachabilityRef reachability
= SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *) &zeroAddress);
if (reachability == nil) {
return NONE;
}
SCNetworkReachabilityFlags flags;
if (!SCNetworkReachabilityGetFlags(reachability, &flags)) {
return NONE;
}
if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
return NONE;
}
if (((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0)
&& !(((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0 || (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)
&& (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0))
{
return NONE;
}
if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
return CELLULAR;
} else {
return WIFI;
}
}
Application package name. (example: co.ab180.ablog)
Bundle.main.bundleIdentifier
NSBundle.mainBundle.bundleIdentifier;
Application version name. (example: 1.0.0)
Bundle.main.infoDictionary?["CFBundleShortVersionString"]
[NSBundle.mainBundle.infoDictionary objectForKey:@"CFBundleShortVersionString"];
Timestamp(milliseconds) of when the event was sent. (example: 1581043739682)
UInt64(Date().timeIntervalSince1970 * 1000)
[NSNumber numberWithUnsignedLongLong:NSDate.date.timeIntervalSince1970 * 1000];
Was this page helpful?