
- Removed YuMi/Library/ (138 MB, not tracked) - Removed YuMi/Resources/ (23 MB, not tracked) - Removed old version assets (566 files, not tracked) - Excluded Pods/, xcuserdata/ and other build artifacts - Clean repository optimized for company server deployment
174 lines
5.0 KiB
Objective-C
174 lines
5.0 KiB
Objective-C
//
|
|
// YYUtility+App.m
|
|
// YYMobileFramework
|
|
//
|
|
// Created by wuwei on 14-5-30.
|
|
// Copyright (c) 2014年 YY Inc. All rights reserved.
|
|
//
|
|
|
|
#import "YYUtility.h"
|
|
#import <CoreTelephony/CTTelephonyNetworkInfo.h> //为判断网络制式的主要文件
|
|
#import <CoreTelephony/CTCarrier.h> //添加获取客户端运营商 支持
|
|
#import "ClientConfig.h"
|
|
|
|
|
|
|
|
|
|
@implementation YYUtility (App)
|
|
|
|
+ (id)valueInPlistForKey:(NSString *)key{
|
|
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
|
return [infoDictionary objectForKey:key];
|
|
}
|
|
|
|
+ (NSString *)appVersion{
|
|
static NSString *appVersion = nil;
|
|
if (!appVersion) {
|
|
appVersion = [self valueInPlistForKey:@"CFBundleShortVersionString"];
|
|
}
|
|
return appVersion;
|
|
}
|
|
+(NSString *)getLanguage{
|
|
NSString *language = [[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] firstObject];
|
|
return language;
|
|
|
|
}
|
|
+ (NSString *)appName {
|
|
#ifdef DEBUG
|
|
NSString *isProduction = [[NSUserDefaults standardUserDefaults]valueForKey:@"kIsProductionEnvironment"];
|
|
if([isProduction isEqualToString:@"YES"]){
|
|
return @"youmi";
|
|
}
|
|
return @"molistar";
|
|
|
|
#else
|
|
return @"youmi";
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
+ (NSString *)appBuild{
|
|
static NSString *appBuild = nil;
|
|
if (!appBuild) {
|
|
appBuild = [self valueInPlistForKey:(NSString *)kCFBundleVersionKey];
|
|
}
|
|
return appBuild;
|
|
}
|
|
|
|
+ (NSString *)appBundleId{
|
|
static NSString *appBundleId = nil;
|
|
if (!appBundleId) {
|
|
appBundleId = [self valueInPlistForKey:(NSString *)kCFBundleIdentifierKey];
|
|
}
|
|
return appBundleId;
|
|
}
|
|
|
|
|
|
+ (NSString *)svnVersion{
|
|
static NSString *svnVersion = nil;
|
|
if (!svnVersion) {
|
|
svnVersion = [self valueInPlistForKey:@"SvnBuildVersion"];
|
|
}
|
|
return svnVersion;
|
|
}
|
|
|
|
static NSString * const kMobileFrameworkResourceBundleName = @"YYMobileFrameworkRes";
|
|
|
|
+ (NSURL *)URLForMobileFrameworkResourceBundle{
|
|
return [[NSBundle mainBundle] URLForResource:kMobileFrameworkResourceBundleName
|
|
withExtension:@"bundle"];
|
|
}
|
|
|
|
+ (NSString *)pathForMobileFrameworkResourceBundle{
|
|
return [[NSBundle mainBundle] pathForResource:kMobileFrameworkResourceBundleName
|
|
ofType:@"bundle"];
|
|
}
|
|
|
|
+ (NSString *)buildType{
|
|
#ifdef DEBUG
|
|
NSString *isProduction = [[NSUserDefaults standardUserDefaults]valueForKey:@"kIsProductionEnvironment"];
|
|
if([isProduction isEqualToString:@"YES"]){
|
|
return @"RELEASE";
|
|
}
|
|
return @"DEBUG";
|
|
#else
|
|
return @"RELEASE";
|
|
#endif
|
|
}
|
|
|
|
+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)fileURL{
|
|
if (![[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]]) {
|
|
NSLog(@"File %@ dosen't exist!", fileURL);
|
|
return NO;
|
|
}
|
|
|
|
NSError *error = nil;
|
|
BOOL result = [fileURL setResourceValue:[NSNumber numberWithBool:YES]
|
|
forKey:NSURLIsExcludedFromBackupKey
|
|
error:&error];
|
|
if (!result) {
|
|
NSLog(@"Error excluding '%@' from backup, error: %@.", fileURL, error);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
static NSString *_from = nil;
|
|
|
|
+ (NSString *)getAppSource{
|
|
if (_from == nil) {
|
|
if (isEnterprise == NO) {
|
|
_from = ISTestFlight ? PI_Test_Flight : @"molistar_enterprise"; // 企业包
|
|
}else {
|
|
_from = [ClientConfig shareConfig].isTF == YES ? PI_Test_Flight : PI_App_Source; // Test_Flight包或appstore App Store包
|
|
}
|
|
}
|
|
|
|
return _from;
|
|
}
|
|
|
|
+ (BOOL)isFromAppStore{
|
|
if([[[YYUtility getAppSource] lowercaseString] isEqualToString:@"appstore"]){
|
|
return YES;
|
|
}
|
|
return NO;
|
|
}
|
|
|
|
|
|
+ (NSString *)removeSpaceAndNewline:(NSString *)str{
|
|
NSString *temp = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
|
|
temp = [temp stringByReplacingOccurrencesOfString:@"\r" withString:@""];
|
|
temp = [temp stringByReplacingOccurrencesOfString:@"\n" withString:@""];
|
|
return temp;
|
|
}
|
|
/// 获取运营商信息
|
|
+ (YYUtilityTelephonType)getOperatorInfomation {
|
|
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
|
|
//NSLog(@"info = %@", info);
|
|
CTCarrier *carrier = [info subscriberCellularProvider];
|
|
//NSLog(@"carrier = %@", carrier);
|
|
if (carrier == nil) {
|
|
return YYUtilityTelephonType_Link_Unknown;
|
|
}
|
|
NSString *code = [carrier mobileNetworkCode];
|
|
if (code == nil) {
|
|
return YYUtilityTelephonType_Link_Unknown;
|
|
}
|
|
if ([code isEqualToString:@"00"] || [code isEqualToString:@"02"] || [code isEqualToString:@"07"]) {
|
|
return YYUtilityTelephonType_Move;
|
|
} else if ([code isEqualToString:@"01"] || [code isEqualToString:@"06"]) {
|
|
return YYUtilityTelephonType_Link_Together;
|
|
} else if ([code isEqualToString:@"03"] || [code isEqualToString:@"05"]) {
|
|
return YYUtilityTelephonType_Link_Telegraphy;
|
|
} else if ([code isEqualToString:@"20"]) {
|
|
return YYUtilityTelephonType_Link_Tietong;
|
|
}
|
|
return YYUtilityTelephonType_Link_Unknown;
|
|
}
|
|
|
|
@end
|