Motion & Fitness on iPhone 5/5C - iphone

From what I know iPhone 5/5C do not have the motion processor like 5S and newer phones have, but when I request the motion permission the default alert with Allow and Don't allow still appears, even if I check before if the motion is available for device with MotionManager.isDeviceMotionAvailable. I would expect the alert not to appear for 5 and 5C.
What am I doing wrong here? Does 5 and 5C actually support motion?

No, you are getting this wrong; isDeviceMotionAvailable detects the presence of a gyroscope and an accelerometer. It's actually available since iOS 4, which came out way before the M7 motion coprocessor inside the iPhone 5s.
From Apple Documentation:
The device-motion service is available if a device has both an accelerometer and a gyroscope.

As #the4kman said the device motion is available through accelerometer and a gyroscope.
But what I actually meant and needed in this case is the user's activity, which is available through the M7 processor that is installed on 5S and newer and to check if that is available on a device I did CMMotionActivityManager.isActivityAvailable()

Related

iOS 9.2.1: iBeacon region monitoring bug

I deployed the same iBeacon region monitoring code in 7 devices. One of them, iPhone 6 running iOS 9.2.1, is regularly failing to detect beacon states (inside, outside, etc..).
I tried with and without SIM card and when the SIM card is inserted it gives better results. However, when compared to an iPhone 6 running iOS 9.2.3 and one running iOS 9.2.1 it gives worst results (the latter two iPhone's always detect the region).
Have you experienced the same in this version of iOS (iOS 9.2.1)?
Is this an known official Apple bug?
My theory behind this:
iBeacon region monitoring uses iPhone location, iPhone location can be
improved using Wi-Fi and phone signal and possibly also accelerometer
and gyroscope data.
iOS could be using these in combination withe the Bluetooth data to
"tune" the beacon ranging thread (in other words if a significant
location happens then the background monitoring frequency will be
increased). Hence if this tuning is depending on the SIM card
information there could be a version of iOS where they put a stronger
dependency on the SIM card presence leading to what I am observing.

CMMotionActivityManager isActivityAvailable devices

I want to use CMMotionActivityManager, I would like to know what devices motion data is available on? Many of the places that i have read suggest that it is currently only on devices that have the M7 chip.
https://developer.apple.com/library/ios/documentation/CoreMotion/Reference/CMMotionActivityManager_class/Reference/Reference.html#//apple_ref/occ/cl/CMMotionActivityManager
isActivityAvailable will return true on the M7 equipped devices:
iPhone5S
iPad mini with retina
iPad Air
Apple is not telling implicitly in the documentation, perhaps leaving other implementation options open and allowing the customer to disable the tracking sensor for privacy reasons.

Detect if Device has GPS

How to detect if GPS is available?
The iPod touch and iPad WiFi version don't have GPS, they have something else based on WiFi.
Anyway, how to know if GPS is available?
Or how to detect iPod Touch or iPad Wifi model?
This is a common difficulty on iOS... One way would be to get a location and check if the altitude is present.
if a valid altitude is present, the position has most probably been computed using GPS
else either the GPS has not picked-up any signal yet or it is not present.
Anyway on iOS Apple has a single interface for all location providers because they intend the developers to express their requirements in terms of accuracy, the control of the technology used should be left to the OS.
Not sure yet if my solution will cover every device... but... What I do is if it's an iPad ask if the device has a cellular connection (Know if iOS device has cellular data capabilities). If so, it will most likely also have GPS.
Not sure if this will cover every device correctly, but at least my test-devices are detected correctly.
To be 100% sure that it is a GPS loaction, check for attribute course. if this is valid then its from GPS. but when not moving course is invalid too.
you can use that condition as initial trigger that now you have GPS.
If you need an initial valid GPS when not moving, check for
vertical accuracy < 100 and horicontal < 50m

Simulating accelerometers, microphone and camera in XCode

Is it possible to simulate movement (ie the accelerometers), microphone and camera in the XCode simulator?
If so, how do you do it?
If not, are there any XCode addins or third party apps that do it? (apart from downloading to an actual iPhone of course).
Thanks in advance!
The easiest way I found to do it is using the Wavefront Accelerometer Data App that can be found in the App Store. All you need to do is add a single file to your application then you can use the accelerometer in your iPhone or iPod touch to send data to your app in the simulator. You'll need a WiFi connection, and a device to use.
You could probably find a solution that runs on the desktop, but you won't be getting accurate real life readings.
I would recommend getting an actual device or your app can behave different than you expect it to. If this is a serious endeavor, you should be able to justify the cost of a device. An iPod Touch is much cheaper but you don't get the phone or camera capability. You can get a headset that has a microphone though.
Those are the limitations, I don't think it wise to develop an app without testing it on a device. I've run into apps that crash all the time and figure it's because they are getting away with stuff in the simulator that you can't do in the memory and cpu constraints of the device.
Microphone works in the simulator. It uses a standard mic input from your mac.
Check this link....
http://media.wiley.com/product_data/excerpt/72/04705009/0470500972-1.pdf
and go to 10 th page..
However, the iPhone Simulator, being a software simulator for the real device, does have its
limitations. Features not available on the iPhone Simulator include:
Obtaining location data — it returns only a fi xed coordinate, such as Latitude 37.3317
North and Longitude 122.0307 West
Making phone calls
Accessing the Accelerometer
Sending and receiving SMS messages
Installing applications from the App Store
Camera
Microphone
Several features of OpenGL ES
In the android simulator the hardware can't be simulated .. but for example for the camera i see an approach to get real information ... Use your webcam .. to do that you can get frames with an app and send this data with a socket to the simulator... maybe it's possible to do that with iPhone simulator.
I see this solution here

What is the difference between iPod touch and iPod touch 2nd generation?

When submitting an app to the app store what is the real difference between iPod Touch and iPod Touch 2nd generation?
The following:
Slightly thinner
Built-in support for Nike+
Volume bar
External speaker
Faster processor (533MHz vs 400MHz)
Supports new headphones with the microphone and volume control (allowing you to use VOIP apps)
Also, 2G iPod touches have microphone input capabilities and a built in speaker, as well as external volume buttons.
Also, the physical back of the device is curved, making it easier to hold.
The first-gen iPod touch doesn't ship with iPhone OS 2.0, which is required to run App Store apps. End-users can purchase iPhone OS 2.0 for their first-gen iPod touch from Apple.
From an SDK perspective, I'm not sure what, if anything, has changed.