Question

I'm trying to get the user agent from my iphone application. It is not webview from the ios application.

agent = UserAgent.parse(request.user_agent)
if agent.mobile?
  #soemthing
else
  if agent.os.present?
     #something
  end

  if agent.browser.present?
     #the result fall on here which give me the application name of the IOS app
  end
end

So, how m I able to detect it in another way or customize the user agent from ios native app?

Besides, I think I found maybe it is bubblewrap issue When I do

request.user_agent

the useragent I get was

App Name/0.2 CFNEetwork/609.1.4 Darwin 13.0.0

Can I customize the APP NAME into other form?

Was it helpful?

Solution

If you're using bubblewrap in your RubyMotion app, you can pass along a headers hash in the options in the request, and set the user agent there.

BW::HTTP.get('http://example.com/api-endpoint', headers: { 'User-Agent' => 'SomeRandomUserAgentString' })

That should do it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top