I want to be able to detect on my ruby on rails server side that a http request has come from a webView component in my app. The app is using react-native. I have tried setting the following in the AppDelegate.m file
NSURL *url = [NSURL URLWithString:@"http://localhost:3000/signin"];
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
[request addValue:@"GolfMentor" forHTTPHeaderField:@"User-Agent"];
[request addValue:@"GolfMentor" forHTTPHeaderField:@"X-MY-CUSTOM-HEADER"];
NSLog(@"%@", [request allHTTPHeaderFields]);
and the output in the console is
GolfMentor[63924:12437749] {
"User-Agent" = GolfMentor;
"X-MY-CUSTOM-HEADER" = GolfMentor;
}
So the customer header appears to be set. However, when I view the request header in my ruby on rails app, there is no sign of the custom header. It looks like my changes are being overwritten latter in the execution of the react-native app. So where and how should I set the custom header? I am also interested in do the same thing for an android version of the app?
