0

For example website 'm.freemyapps.com' denies all the browsers and even UIWebView and requests Safari only.

Is it possible to make my app present itself as Safari?

Gargo
  • 1,135
  • 1
  • 10
  • 21

1 Answers1

1

If I understand your question correctly, you can do any of the two things-

1) You can redirect the user to leave the app and open the mobile site in Safari.

2) For mobile site support, the UIWebView might need to add additional User-Agent header fields in the request, mimicking Safari. e.g.

NSURL *url = [NSURL URLWithString:@"m.freemyapps.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setValue:@"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like   Gecko) Version/3.0 Mobile/1A543a Safari/419.3" forHTTPHeaderField:@"User-Agent"];
[webview loadRequest: request];

In most of the cases, this solution should work. If this does not, you should find out with the server side implementation of the particular mobile site as to whether it requires additional headers to be sent.

Subzero
  • 841
  • 6
  • 20
  • thanks but freemyapps still rejects my app. And I can't use Safari as outer app – Gargo Oct 20 '13 at 09:37
  • Hmm..ok. You can still experiment using different User-Agent combinations- can find here- http://www.useragentstring.com/pages/Safari/. You can also check the specific user-agent version on your device mobile safari page by opening http://whatsmyuseragent.com and then try using that in the webview loadRequest. If nothing works, you should speak with m.freemyapps.com guys. – Subzero Oct 20 '13 at 10:07
  • I just checked the m.freemyapps.com site and found the following info- System Requirements: iOS 6 or greater is required You must use FreeMyApps with the Safari browser Settings > Safari > Accept Cookies must be set to 'Always' or 'From visited' Settings > Safari > Private Browsing must be set to OFF So, I think they are setting cookies- you should try setting the Cookie header in the request and once you get the response, you should extract and store it. See this for some guidance- http://stackoverflow.com/questions/12069622/uiwebview-enable-cookies – Subzero Oct 20 '13 at 10:21
  • it uses JQuery and I don't understand this technology enough to try to represent my app as Safari. – Gargo Oct 20 '13 at 19:46
  • Any luck so far? What do you mean by "try to represent my app as Safari" ? Why do you want to do that? Or, do you try to mean something else? Could you please elaborate? – Subzero Oct 21 '13 at 20:42
  • i want to write a reminder which sends local notifications for new offers. But when this website sends different pages for safari and other browsers (including `UIWebView`) – Gargo Oct 26 '13 at 18:37