Parse json extensions; that's the answer.

On Sunday, 20 April 2014 05:45:07 UTC+1, Jeremy Burns wrote:
>
> So I guess my next question is: "What is the best way to determine if a 
> request is coming from an iOS device (or Android etc) rather than a mobile 
> browser so that I can return JSON data instead of rendered HTML?
>
> On Sunday, 20 April 2014 05:39:26 UTC+1, Jeremy Burns wrote:
>>
>> I have isolated the issue. In my AppController beforeFilter function I 
>> have these lines:
>>
>> if ($this->request->isMobile()) {
>> Configure::write('debug', 0);
>> $this->RequestHandler->renderAs($this, 'json');
>> }
>>
>> This is so that the iOS app we are developing alongside the web app can 
>> get the JSON output it expects. It seems that isMobile is returning true 
>> even when viewed from mobile safari.
>>
>>
>> On Saturday, 19 April 2014 08:20:22 UTC+1, Jeremy Burns wrote:
>>>
>>> I have a site (test.nudgedeck.com) that renders as expected in web 
>>> browsers. But when viewed in mobile Safari all I see is this:
>>>
>>> <html>
>>>
>>> <head></head>
>>> <body>
>>>
>>> <pre style="word-wrap: break-word; white-space: pre-wrap;">[]</pre>
>>>
>>> </body>
>>>
>>> </html>
>>>
>>> Any clues what this could be? CakePHP 2.4.7 fully installed.
>>>
>>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to