0

I created a responsive app and a native app: the native app is basically just a UIWebView containing the responsive app.

How can i check on server side (php, etc..) where the request comes from?

Is there any possibility to modifiy requests sent from UIWebView or something else?

sdabet
  • 18,360
  • 11
  • 89
  • 158
Creative crypter
  • 1,348
  • 6
  • 30
  • 67

1 Answers1

1

I see two possible approaches:

URL parameter

You could have a parameter in your URL to indicate the source of the request.

For instance, if the URL if your web app is

http://myserver.com/mypath

you could use the following URL in your native app's UIWebView:

http://myserver.com/mypath?src=native

On server side, you can retrieve this paramerer, e.g in PHP:

$src = $_GET['src'];

if ($src == 'native') {
    // Request from native app
}

If your app has multiple pages, then you should modify the way your links are created to propagate this parameter when navigating from one page to another one.

Cookie

In the native app, you could manually set a custom cookie which would be sent along your requests and which you would retrieve on server side.

The following post may help you for that: Is it possible to set a cookie manually using sharedHTTPCookieStorage for a UIWebView?

Community
  • 1
  • 1
sdabet
  • 18,360
  • 11
  • 89
  • 158