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.
Related
I'm working on an app that needs to access wifi signal strength. I don't need to publish it to the app store so I don't care if the method is approvable or not. I've looked high and low but can't seem to find a way to get this info. The best I've found is this guide:
https://www.progressioapps.com/get-wifi-information-on-ios-with-swift/
But the statusBar can't be accessed in the same way on iOS 13. Any ideas?
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.
I was wondering if my code was broken, or if even a jailbroken (multitasking activated) iPhone 3g maybe doesn't support this.
I create a CLLocationManager, set the delegate and so on, and tell it to "startMonitoringSignificantLocationChanges". Whenever the app is then called, I log that to a textView. But nothing ever happens. Not if I drive 5km or 20km.
So I thought, well lets dig a little. I found this API:
NSLog(#"Location Change Available: %i\n", [CLLocationManager significantLocationChangeMonitoringAvailable]);
Sadly it returns a zero :[
So, what I'm asking is: Did anyone get it to work on a 3g? Any hints? Impossible?
iOS4 brings two new background modes to Core Location: startMonitoringSignificantLocationChanges and startMonitoringForRegion:desiredAccuracy: using CLRegion.
The latter only works on the iPhone 4 device, likely due to new GPS hardware in the device. I confirmed this w/ an Apple rep on the Apple developer forums.
However, I have successfully tested startMonitoringSignificantLocationChanges on a 3GS. I have tested the same code on a jailbroken 3G as well as a vanilla 3G. I believe that simply the answer is that Apple has decided not to enable this feature on the 3G due to lack of resources.
When that feature is enabled, your program will be launched in the background when a significant location event occurs. This background multitasking may stretch the 3G to its limits (in Apple's eyes). Apple's documentation on this subject is VERY unclear about which devices support what. It says "call these methods, and rely on what they return". I've already posted on their developer forums that I wish they would just make it CLEAR which devices support which modes.
Apple's "official" documentation for testing for availability
My blog post documenting how this works on 3GS, iPhone 4
I tried this yesterday, got the same result. I have a jailbroken iPhone 3G running iOS4 with multitasking activated.
[CLLocationManager significantLocationChangeMonitoringAvailable] returns 0
If I use [manager startUpdatingLocation], it does work in the background, but it's using a lot of resources.
I am currently developing a location based iPhone application. Is there any way to test the app other than taking the iPhone to different places?
Thanks
Yes, you can.
Try this: http://www.vimov.com/isimulate/
(...) With iSimulate installed on their iPhones however, their multi-touches on the iPhone (which gets interpolated for the larger iPad screen), the movement recorded by the accelerometer, the location and orientation captured by the GPS and Compass, all get wirelessly sent to the iPad Simulator, so they can develop virtually any application they want, before the iPad is itself released!
Even though an answer have long been accepted for this question I'll still chime in with some additional information on the topic.
The kind folks at FutureTap have mad the FTLocationSimulator available for free at GitHub. It allows you to prepare a test route using for instance Google Earth, and then have the simulator feed these coordinates to your app.
I've written a blog post about how to use FTLocationSimulator to easily switch between multiple routes during testing of the location features.
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