diff --git a/vendor/brave-ios/Ledger/BATBraveLedger.h b/vendor/brave-ios/Ledger/BATBraveLedger.h index 9bf23ef7848a..3c7100761797 100644 --- a/vendor/brave-ios/Ledger/BATBraveLedger.h +++ b/vendor/brave-ios/Ledger/BATBraveLedger.h @@ -284,6 +284,8 @@ NS_SWIFT_NAME(BraveLedger) @property (nonatomic, assign) double contributionAmount; /// Whether or not the user will automatically contribute @property (nonatomic, assign, getter=isAutoContributeEnabled) BOOL autoContributeEnabled; +/// A custom user agent for network operations on ledger +@property (nonatomic, copy, nullable) NSString *customUserAgent; #pragma mark - Ads & Confirmations diff --git a/vendor/brave-ios/Ledger/BATBraveLedger.mm b/vendor/brave-ios/Ledger/BATBraveLedger.mm index 3974d86706ed..8d19a8a07b92 100644 --- a/vendor/brave-ios/Ledger/BATBraveLedger.mm +++ b/vendor/brave-ios/Ledger/BATBraveLedger.mm @@ -1792,6 +1792,16 @@ - (void)killTimer:(const uint32_t)timer_id #pragma mark - Network +- (NSString *)customUserAgent +{ + return self.commonOps.customUserAgent; +} + +- (void)setCustomUserAgent:(NSString *)customUserAgent +{ + self.commonOps.customUserAgent = [customUserAgent stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; +} + - (void)loadURL:(const std::string &)url headers:(const std::vector &)headers content:(const std::string &)content contentType:(const std::string &)contentType method:(const ledger::UrlMethod)method callback:(ledger::LoadURLCallback)callback { std::map methodMap { diff --git a/vendor/brave-ios/Shared/BATCommonOperations.h b/vendor/brave-ios/Shared/BATCommonOperations.h index f1c3d677435e..f0026b4d6408 100644 --- a/vendor/brave-ios/Shared/BATCommonOperations.h +++ b/vendor/brave-ios/Shared/BATCommonOperations.h @@ -36,6 +36,8 @@ typedef void (^BATNetworkCompletionBlock)(int statusCode, #pragma mark - Network +@property (nonatomic, copy, nullable) NSString *customUserAgent; + /// Loads a URL request - (void)loadURLRequest:(const std::string&)url headers:(const std::vector&)headers diff --git a/vendor/brave-ios/Shared/BATCommonOperations.mm b/vendor/brave-ios/Shared/BATCommonOperations.mm index 4c02e1a5b22c..0eaa80701a87 100644 --- a/vendor/brave-ios/Shared/BATCommonOperations.mm +++ b/vendor/brave-ios/Shared/BATCommonOperations.mm @@ -97,7 +97,12 @@ - (void)loadURLRequest:(const std::string &)url headers:(const std::vector 0) { + [request setValue:self.customUserAgent forHTTPHeaderField:@"User-Agent"]; + } if (content_type.length() > 0) { [request setValue:[NSString stringWithUTF8String:content_type.c_str()] forHTTPHeaderField:@"Content-Type"];