So this seems to work...
In AppController->beforeFilter():
if ($this->request->isMobile()) {
$this->RequestHandler->renderAs($this, 'json');
}
Now all mobile requests (including redirections) se the json equivalent
view (e.g. /Views/Users/json/login.ctp instead of /Views/Users/login.ctp)
even if the mobile app posts to the non json extension.
On Friday, 4 April 2014 11:50:00 UTC+1, Jeremy Burns wrote:
>
> In our continued head long plunge into iOS app integration we have now got
> the iOS app talking nicely with the Cake controller code using json,
> Router::parseExtensions(); and json views. The next challenge is
> redirecting.
>
> For example, the Auth component's loginRedirect is set to a non json view
> (e.g. /users/profile) as that is where the web site expects to go after a
> successful login. When the login comes from the iOS app (via
> /users/login.json) I really need it to redirect to the json equivalent
> (e.g. /users/profile.json) else the iOS receives the fully rendered HTML
> (which is bad).
>
> What's the recommended way of dealing with this? Hard coding json specific
> redirects, or is there something clever available within the RequestHandler
> component that can detect that the current action is a json action and any
> redirect should also be to a json action?
>
--
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.