mirror of
https://github.com/samsonjs/samhuri.net-ios.git
synced 2026-03-25 09:25:47 +00:00
19 lines
934 B
Objective-C
19 lines
934 B
Objective-C
#import <Foundation/Foundation.h>
|
|
#import "OMGUserAgent.h"
|
|
|
|
NSString *OMGUserAgent() {
|
|
static NSString *ua;
|
|
static dispatch_once_t onceToken;
|
|
dispatch_once(&onceToken, ^{
|
|
id info = [NSBundle mainBundle].infoDictionary;
|
|
id name = info[@"CFBundleDisplayName"] ?: info[(__bridge NSString *)kCFBundleIdentifierKey];
|
|
id vers = (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: info[(__bridge NSString *)kCFBundleVersionKey];
|
|
#ifdef UIKIT_EXTERN
|
|
float scale = ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [UIScreen mainScreen].scale : 1.0f);
|
|
ua = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", name, vers, [UIDevice currentDevice].model, [UIDevice currentDevice].systemVersion, scale];
|
|
#else
|
|
ua = [NSString stringWithFormat:@"%@/%@", name, vers];
|
|
#endif
|
|
});
|
|
return ua;
|
|
}
|