Saturday, April 5, 2014

Re: iOS app development

You're talking about json responces so I suppose as an overall service pattern you are using REST?

1. For the redirects
Well in that case, REST dictates that you need to use HTTP's facilities. I am saying this especially for the redirects.
You don't need to send redirects as information in JSON - just send the redirect header and have the iOS application
handle it as a HTTP header.

2. About $this->request->isMobile() and the simulatior

99% it is because of the simulator. Check out the code in isMobile() and then make the simulator simulate it better. :D
Try NOT TO change the code in isMobile() but rather see why the simulator is not being recognize. Then try to make to simulator pass whatever is needed so it is recognized.

3. The RequestHandler in general

This Component is there to assist you in recognizing properties of requests. Generally it is used " to obtain additional information about the HTTP requests that are made to your applications".
Think of it as a wrapper that

5. CakePHP & iOS resources

I don't think there are specific resources for interoperability.
The basic idea is a Client - Server application. Let's say you use REST.
Client is iOS. As far as I know most people use RestKit as a service consumer.
On the server side you will always have a Service - doesn't really matter if it is CakePHP or .NET.

Client recognition also ties in here. You are not obliged to use only the isMobile() method.
I would actually encourage you to add a custom way for your server to know that it is your App since you are developing the Server and App at the same time.
But this is a big IF.
This way the API is always sure that your App is calling it - isMobile() will return true even If you call your API from an Android device.
This could be:
- a custom header that the iOS App always sends in all of your requests
- an extension of RequestHandler in a method like 'isMyApp()' which will inspect requests for the header

This tactic could be a double-edged knife and you should always use it in conjuction with isMobile().
Watch out how exactly you implement this, because you may end up chaining your Service to your App - which is not the envisioned result of this approach and should be avoided.

Cheers,
   Borislav.


On Thursday, 3 April 2014 13:28:54 UTC+3, Jeremy Burns wrote:
We're developing an iOS app alongside a CakePHP web app. At this point the iOS developer is using the XCode simulator. I have some questions about how the PHP code should be altered to handle requests from iOS. We are learning as we go along...

- When I do a check for $this->request->isMobile() the result is false; is that because we are using the simulator?
- When the right data is posted from the log in screen the users controller redirects the user to the next page. The iOS app is receiving the full HTML of that page. Do I need to put isMobile() checks throughout my PHP code and return different responses? See the false isMobile check above.
- What part does the RequestHandler component play in this? I have included it in AppController.
- The CakePHP app contains al the correct redirects and logic flow. Does the iOS app need to replicate these (in other words, the logic is stored in two places) or can the CakePHP code drive the redirect equivalent statements for iOS?
- Are there any good resources for co-developing iOS and CakePHP apps?

--
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 cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: