I would like to check if the user is using an iPhone 4 or not. How can I do that ?
Thanks !
Sebastian
Apple specifically recommends against this, instead preferring that you check for individual features and act according to these. This makes your life a lot easier when Apple releases new hardware; if for instance Apple releases an iPod Touch with a camera, and you need a camera for your app, your users wont be upset that it tells them "No camera found" when it does have one, all because it reports as not an iPhone. Here is one way to require all the differentiating hardware features. Do not use these for enabling/disabling features that are supported but not required: this can be determined at runtime through the APIs used to interact with that feature.
UIDevice (see here, also the docs) can help you determine if it is an iPhone, but again, don't do this.
To detect the difference between the iPod Touch and the iPhone, we use
if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
There might be something similar to check for a the forward camera.
Related
I want to capture all the touch events at the system level, I do not mean capturing at one specified app, but all the apps even the SpringBoard.I tried IOHIDEvent(https://github.com/kennytm/iphone-private-frameworks/tree/master/IOKit/hid), but the runtime headers was changed after iOS4, and now I can not get them of iOS6.
May be GSEvent is also a good way, but does anyone known how to do this by GSEvent?
Thank you!
Take a look at EntryDevLevel excellent answer here on how to capture and record clicks on iOS using iOHID:
iOS touch event notifications (private API)
BTW. His solution works on non jailbroken iOS either.
Apple's Location Awareness Programming Guide suggest to include the location-services and possibly the gps for UIRequiredDeviceCapabilities.
My app requires the Region Monitoring APIs. How do I ensure only capable devices can see my app in the store?
You're right, location-services and gps will allow devices other than the iPhone 4 to install your app. You could pick some other feature though that you know is iPhone 4 exclusive, like camera-flash or gyroscope and require that one.
I'm not entirely sure whether apple will frown upon a restriction without an apparent need, however gyroscope appears to me like a likely restriction in a navigation enabled app. If you try this approach, I'd explain things in the text field for the comments to the reviewers. Another caveat would be that you'd risk that a future device wouldn't "fit in" - an hypothetical iPhone mini which would feature region monitoring but lacking a gyroscope or camera flash wouldn't be able to install your app, for example.
To be entirely honest, If I were you, I'd ask apple to make sure.
Check out UIRequiredDeviceCapabilities - Apple Developer Documentation. Basically exactly what you said. Are you looking for instructions on how to do that?
If I create an App for the iPhone (OS 3) will it run without modification on an iPod Touch or will I need to create a separate binary? If it is the same runtime, does it just have stubs for the iPhone only features or do you have to check feature by feature using UIDevice to ensure the particular class/method is supported on the device to avoid a crash?
Sorry for the elementary questions, can't find a simple explanation of this anywhere.
Cheers
Dave
EDITED: Based on discussions below:
How can you check if a device supports making calls? At the moment I am assuming if it is an iPod Touch it can't. Is there a way of finding out what shared applications/URL schemes are supported by a device?
You shouldn't really try to guess what the device is. You're far more future-proof if you test for the specific functionality you're trying to use. After all, in the future there might be iPods with cameras. Or compasses (which are on some iPhones but not others).
Since it sounds like all you want to do is see if you can open a URL, why not use -[UIApplication canOpenURL:] ? (This would presumably work on iPod touches that had applications that could handle VOIP -- I don't know if any such exist, but I think it's an example of why you need to test for functionality and not make assumptions based on hardware or OS version.)
The app will run on an iPod touch, no need to compile a separate version. Features that require an iPhone (e.g. camera) will not work, obviously.
What such features do you intend to use? You may provide alternatives for iPod users or alert them that e.g. no camera is available.
This question adresses how to check if a microphone is present: Detecting iPhone iPod touch accessories
I'm writing an app that needs to function differently if it is running on different models of the iPhone/iPod Touch. How can I check if the app is running on 3GS, 3G or other?
See here:
how do I detect whether I have iPhone 2G,3G,3GS
The UIDevice class provides some information like this.
But you're probably much better off testing for capabilities ("does this device support compass headings?") than for specific models ("is this device a 3GS?"). What is it that you're trying to do?
Edit: for the specific example I presented above, see the headingAvailable property of CLLocationManager. It will be YES if and only if heading information can be obtained from the device.
Which of the new features are you looking forward to the most in iPhone SDK 3.0?
Is it one of the main advertised six new things, or something smaller? Something in the "1,000 new APIs", perhaps?
Phone to phone communication via bluetooth seems like it will terribly useful for some apps I am writing. No longer do you have to input all the data you want to store yourself, you can share some of it with other iPhone users.
not really a feature, but the best thing about developing the iPhone SDK further is the great frameworks that arise. there are some really, really great frameworks out there already (like the Three20 project) which will become even better with the new 3.0 SDK.
my real excitement will take over once they let us run background processes. maybe in 4.0?
Video! The ability to write decent tools for mobile video uploads is a big draw.
MapKit by far will bring the biggest change sweeping across the app space.
My personal favorite is that we can finally easily track upload progress of large files (like images).
I really, really want to see fixes in the camera API so that it isn't either broken (2.2.1) or forcing a switch to portrait (3.0).
Apart from that, the most useful features to me are:
push notifications. Great for making an app more sticky - you can let the user know that something of interest to them has happened.
CoreData - I've been using a third-party SQL layer, but it's a little buggy and no longer supported.
Peer-peer bluetooth, as the poster above said, is also useful for local data exchange.
And the least useful? Cut and paste. I actually want to disable it in my app (to discourage people from copying content) - and it doesn't look as though you can (yet).
Bluetooth phone-to-phone communication with GameKit will enable a host of currently impossible applications. Multiplayer games with no WiFi network needed and data exchange between two phones are obvious use-cases.
I'd also like to see - not currently included in the betas - a decent camera API that allowed us to customize the appearance of the capture screen, and as another poster said, have it work properly in landscape and portrait mode.