Shake functionality in a music application - ios

I have developed a small music app by using AVPlayer and MPMediaPickerControlLibrary with all the normal required functionalities for a music app. The app is also capable of running in the background when the screen is locked.
Now, what I want is to start the app when the screen is locked through a shake and soon as the app starts the current song should start playing.
I am not able to achieve this from a long time
Any suggestions on this will be highly appreciated or any other workaround apart from shake to turn on the music in the app when the screen is locked in iPhone.
Thanks in advance.

You need to implement the a CMMotionManager object, but keeping it running all the time in background will be a major power consumption issue.
Modifying the updateInterval property to reduce the number of updates will defeat the purpose, given that you may miss a shake in background.
Now, if the app was terminated by the user, then no motionManager object will be available until the user launches the app again.

Related

invoke a alarm sound when ios app is in background and someone pick it, using core motion

invoke a alarm when someone touched the iPhone or iPad and a app is running in background.
this is happening into a ios app i.e. iAntiTheft
iAntiTheft is not using the location i checked the permission of the app, in a scenario i put the app in background activating motion alert and device get's locked after some time, now i pick the device, it immediately show a Notification and start alarm on high volume.
one More thing here to notice it always playing a low volume beep beep after enabling the motion sensor alert. any help appreciated.
how can i achieve this.
The answer to get Core Motion Update when the app is in background and the device locked. in both case just put an audio with background mode playing after the core motion updates function, now the device will go to background or get locked you always getting the core motion coordinates updates
Repo Link Providing soon

ios app, running accelerometer while the app is in the background

I have an app using accelerometer. When a certain motion is detected, i am trying to make my iphone vibrate. While the app is in the foreground, and I conduct a certain motion, it vibrates. But it does not when the app is in the background.
I have a counter that detects this motion. When I execute this motion while in the background for three times, although it does not emit any vibration, after I transition back to foreground, the counter is increased by three. So I know the accelerometer is working. Or is putting the motions in a queue and executing it when the app comes back to foreground.
And I'm not making a rookie mistake by touching the phone's vibrate to off.
I'm quite not sure where to go from here. Is iphone inherently not capable of capturing and processing accelerometer data while in the background? Or is there something I'm not doing correctly?
In iOS there are only a certain type of activities allowed in background. Here you can check them: Background Modes.
I'm currently working in an app that uses sensors like the accelerometer and I get updates from it using the CoreLocation delegate method didUpdateLocation, since using the GPS to locate the device is one of the Apple allowed background modes. I hope this helps you!

iOS - App in Background vs Local Notifcations

I'm building a project which is something like an Alarm Clock app. I know there are inherit limitations here (as compared to the built-in Apple Clock app) but I'm trying to assess if these limitations will be a blocker.
In the end, I need to be able to schedule an alarm/notification at a certain time, and have it sound when the phone is locked. Furthermore, I want to be able to interact with the app from the lock screen (including shake and volume gestures).
Does this require me having the app run in the background, and scheduling LocalNotifications? If its in the background, and the LocalNotification fires on the lock screen, is it possible for the User to interact with the application? i.e. With the app SleepCycle, you can shake the phone from the lock screen to trigger a Snooze. Is that sort of functionality possible only because the app is running in the background (in the case of that app, I know it's running in the background)
yes. you need to be running in the background for interacting on the lock screen

Sleep Cycle - What kind of Backgroundmode is this?

I'm currently working on an app which reminds the user, when he gets to an certain location. I want this app working in background as well and searched for solutions.
In the AppStore i found the App called Sleep Cycle, which tracks your activities during your sleep. When you set the alarm, and running the App in the Background you get this screen red bar on the top of the Display of your iPhone.
http://i.stack.imgur.com/uEejp.jpg
Does anybody know what kind of Backgroundmode this is, and how i can transfer it to my app?
Thanks
To have such a red bar I use audio background mode and also I record sound in background. Since Sleep Cycle asks user to allow access to microphone I believe it also records audio in background

IOS App and Background

I have a music signal processor app I want to publish and it needs to run in the back ground. I used to Info-plist to do so with UIBackgroundModes. It runs on IOS7 or less, and the problem I am having is once the phone locks and the app goes into the background I can't get it to come out of the background and its keeps running with the red banner at the top. Some of this I have learned as I go, but I have noticed some run on a timer, but I want mine, since its a music processor to keep going until the phone either unlocks or whatever interrupted it stops.
The app is basically a stomp box used with iRig. If that helps.
Thanks
Can you clarify about what you mean when the phone locks, the app goes into the background and yo can't get it to come out of the background? Are you saying like the app is playing music while the app is locked?

Resources