iPhone headphone click detection - iphone

I've tried looking through the documentation, but I can't seem to find (or recognize) what I'm looking for.
The iPhone and iPod Touch have a momentary switch on the headphones, which I believe is called the "remote" (please correct me if I'm wrong). It is used to start/stop/forward/back for music or to pickup/end a phone call. I'd like to know when this switch is clicked in my native application.
In which framework and classes would I find this?

I don't believe this functionality is supported by any current framework.
If your application has iPod playback during execution you could register for MPMusicPlayerController notifications - Music Player Notifications
This will notify you of the playback state changes you mention above. However, it will not tell you whether the state was changed via the remote or the UI. But it's the only way that I know of to 'guess' if the remote button was clicked - I use this method in one of my own apps.

Related

Flutter persistent notification and service

I'm planning to develop simple audio player, but currently I'm stuck on notification support. I want notification that is persistent while audio is playing and I also need some controls (like play/pause, next/previous) and possibly fanart visible on notification. That's similar as most other player do (Aimp, Google Play Music etc).
I was looking forward for good example how to develop it using Dart/Flutter, well is that even possible without writing native code for each platform (Android/iOS)? Is there any plugin that supports that kind of notification on both platforms? Plus, of course, foreground service bound to it to don't kill audio playback when screen is off.
You might be interested in looking at package:audio_service which seems like it might handle the majority of the work for you, including the handling of background execution and notifications.
Also, for notifications I've had success with package:flutter_local_notifications but you shouldn't need this if you're going to use package:audio_service.

Apple watch event detection

Are anybody aware of any event api for the apple watch ? I'm looking for detecting events like on/off wrist events do determine if glances should be displayed or not.
There are not any events other than the simple ones declared in the various interface controls, like willActivate, didDeactivate, button taps, etc..
There are rumors that the next version of WatchKit this Fall will include more capabilities like being able to run some code on the watch itself, so maybe it'll be possible to have more event notifications once that comes out, but who knows.

Getting notification of iOS device usage in background

Might be i am using a wrong title but i will try to explain here what i want.
In iOS i need to implement a functionality to get notify if the user is using their iOS device.
My app will be running in background using location services and i need to find out if the the user is using their device. It is doable as i have looked into this application which is sending notifications in background to the drivers who is suing their devices while driving.
https://itunes.apple.com/fr/app/cellcontrol/id661169580?l=en&mt=8&ign-mpt=uo=2
So i need similar kind of functionality to find out if a user is using iOS device or not. If anyone of you can suggest me any approach then it would be great for me to start.
Thank you!
Note: I have tried to find out touch events in background but that is not possible as i have done some research on this.
You won't be able to receive touch events when the app is in background using public API's. However, you can do that with the help of mobileSubstrate library ( http://iphonedevwiki.net/index.php/MobileSubstrate - The MobileHooker component is the one that would be used). by hooking your process to the OS. As an example, the display recorder app in Cydia tracks global gestures while recording the screen. This will be a cydia tweak and you will need to jailbreak your device to do all that.
Coming to your specific use-case, the example app you cited should be using one of the exceptions for background applications mentioned in https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html (see the section - "Implementing Long-Running Background Tasks"), probably the one to receive updates from external accessories.

Disable silent mode on iPhone?

How do you disable the user from turning the phone on silent? (switching the switch on the top left of the phone?)
I want my app to always play sound no matter what the state of that switch is. Is this possible?
Thanks in advance...
Please search stackoverflow or the web for similar questions before posting a new one, this question has already been covered:
Play sound on iPhone even in silent mode
iphone, how to play sound even in silent or mute mode?
Be careful about overriding the silent mode switch and playing audio. Apple may not like you doing this, depending on the context; if they don't like it, you will fail app review. Is there a good reason to play audio when in silent mode in the context of your app?
Here’s what I have done that works great!
Set all your contacts Emergency By Pass OFF! Then decide who should break through by turning the Emergency By Pass ON to those important calls you simply can’t miss; Family members like Mom and Dad.
Now your all set to use he Silent switch.

How to create a "return to app" status bar when app goes to the background?

When my app moves to the background while either playing audio or recording audio, I would like to provide something like the the green "In Call" status bar that appears when you are in a call and swap out to another app, giving you a quick "return to app" capability.
I thought this might be a private API, but I noticed the Griffin iTalk app does this when it is recording audio (see picture) - so I know it can be done, but I have not been able to figure out what the API is (the Info.plist setting, the AVAudioSession, the UIApplication/Delegate or the whatever) to make this magic happen. My app is currently working and recording audio in the background and works just fine, I assume there is some bit somewhere I'm not setting to get this behavior.
Can someone either point me to the right docs or sample code that exhibits this behavior? (I've scoured the Audio docs and haven't been able to find it).
Thanks!
There may be a private API to do this, but if you want to get into the App Store, the thing to do is to register as a VOIP app, which gets you the in-call status bar, like Skype or (I imagine) iTalk.
Actually the red-bar actually only appears when the application is recording audio in the background. I've only ever done this when marking the application VOIP and Audio.
You may be able to do this by only marking is as background Audio application only, but I haven't tried this.