1. 程式人生 > >ios開發:AFNetworking3+在請求頭中新增UserAgent方法

ios開發:AFNetworking3+在請求頭中新增UserAgent方法

找到檔案:AFURLRequestSerialization.m

搜尋"userAgent"所在位置, 然後修改即可

userAgent = [NSString stringWithFormat:@"%@/%@ (%@ %@; Apple x64; JpushToken %@; uniqueId %@; source AppStore) ooyby/%@", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion],[JPUSHService registrationID],[JPUSHService registrationID],@"20170630"];