AudioOutputUnitStart replace the Music app - ios

My application (VoIP one) is using kAudioSessionCategory_PlayAndRecord category. Everything is working perfect expecting the fact that When calling AudioOutputUnitStart the Music App is replaced by my application.
Basically if I double tap the home button and flip to the music app, I can't see the default music app, instead I can see my application log near the music controls.
Anybody knows what can be?

Check if you call this somewhere
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
This may cause your app to appear in the music control bar

Related

Is there anyway to stop screen-lock while my app is in foreground in iOS App?

I do not want the user to be able to lock the screen while app is in foreground, even when the user forcefully tries to lock the screen with hardware lock button. Is there anyway to make it function programmatically?
Please do not tell me idleTimerDisabled property of UIApplication class.
[UIApplication sharedApplication].idleTimerDisabled = YES;
It does not work for what i'm looking.
This is not possible using the iOS SDK. You have no mechanism for making the user unable to do things like lock the screen or not press the home button.

iOS: Prevent app from launching into the background

I am currently building a music app which takes controls from the iOS7 control center. One of the features I noticed is that if I press the "play" control button, my app will start, even if it has been killed. This is not something which I want to happen, so I added return NO in didFinishLaunchingWithOptions if the app is launching in the background to prevent the initialization process.
Unfortunately, this does not change the fact that the app has still started, and didFinishLaunchingWithOptions is not called again (and nothing is initialized). Since I cannot have the app forcefully kill itself when I don't want it to start, is there any way to prevent the app from launching? I had thought that returning NO would have done the trick, but this does not appear to be the case.
I have found one of the main causes to this issue. It had to do with the audio session and the various notifications/delegates which the app was registered for. In the AppDelegate's applicationWillTerminate: I had to make sure to call:
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&audioSessionError];
And also unregister for any audio notifications (interrupts and route changes).
Do you want your app to run in the background at all?
If not, you can simply add a info.plist value so it doesn't enter background and just closes when a user hits the home button.

How to display playing indication icon on status bar?

My app plays audio streams, it works fine for all cases such as background etc. I am using AudioToolbox.framework and MediaPlayer.framework to play the audio, my query is when the app starts playing audio i would want the indicator on the status bar to be shown as it does for the default iPod player.
Can anyone guide me on how to display the play indication icon on the status bar as soon as my app starts playing audio and disappears when its paused/ stopped or terminated.
As is described by iHemantk:
You just have to register for remote control events and icon will show
up:
https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/Remote-ControlEvents/Remote-ControlEvents.html#//apple_ref/doc/uid/TP40009541-CH7-SW3
they added this in 4.0... works well. whoever is first responder now
controls the icon... just won't work for anything pre-iOS4: put the
following in your -viewDidAppear method:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
and include this method in the code:
- (BOOL) canBecomeFirstResponder {
return YES;
}
this goes in `-dealloc`:
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
and while not necessary, you may want to include this in the
-viewWillDisappear:
[self resignFirstResponder];

Implementing video calling feature using facetime, (can't back to the application when call ended)

I am trying to make a chatting application, text chatting using APNS and in my app here is another option for video calling. I am using facetime for video calling feature. I have a button name "Video Call", when press this button the following code executes:
NSURL *url = [NSURL URLWithString:#"facetime://someones_apple_id#gmail.com"];
[[UIApplication sharedApplication] openURL:url];
It opens Facetime and call to someones_apple_id#gmail.com
My problem is when the call ended, my Application didn't launch automatically!
Problem in details: Suppose I have two iPad, that installed the same application. This application have a button called video call. The application is running on these two iPads. Now I am pressing video call button to call. Facetime opens in my iPad and the caller iPad. When call ended, my application didn't launch automatically but the receivers application launched automatically.
I tried the same thing in a UIWebView using the following code, but facing the same problem!
<(a href=\"facetime://someones_apple_id#gmail.com\">Video Call<(/a)>
My problem is from caller end, not in the receiver end. I want to back to my application when the call ended. Can anyone help me to solve this issue?
thanks in advance.
Still didn't get the exact solution, but I have found a tricky one::
When call ended from caller end, touch your iPad with four fingers and swipe it down when the iPad is in Landscape mode. When your iPad is in portrait mode swipe it right using four fingers. Now you are seeing your application.
If it doesn't work, then you can swipe left/right/top/bottom using four fingers. One of these will work for you. Actually it depends in which orientation you are now browsing.
thanks.

UILocalNotification how to call certain method if application is in background

I am creating player application, which is playing audio streams through internet. I want to add alarm functionality in my app - in particular time my player begins to play audio stream, I am trying to use UILocalNotification mechanism. But I've difficulties with it when my application in background mode, I can't call 'play' method, when notification is receiced (can't without user interaction). May be it is impossible?
But I bought this application:
http://itunes.apple.com/us/app/radio-alarm-clock-mp3-radio/id380271167?mt=8
And it seems like radio can start playing when local notification is received. Alarm can start playing radio when my app is in background mode.
Earlier I was trying to use NSTimer for this, but when my app goes to background, timer stops. If I use beginBackgroundTaskWithExpirationHandler: it works only 10 minutes. My app has special flag in plist, what is is audio application, and can playing music in background. In this case timers are working. But if I stop playing and go to background, timer is not working.
When I use \Radio Alarm Clock' application, I hear 'white noise' from dinamic, when music in not playing. May be it is the secret of this application?
Can you help me with my problem? Thanks.
maybe it's too late.
I had a look to the app you've mentioned at http://itunes.apple.com/us/app/radio-alarm-clock-mp3-radio/id380271167?mt=8 and yes, I think you are absolutely right, the only way to achieve that the application remains active while in background is to play a fake sound while it is in the background, which should be prohibited by Apple.
I've also seen that they don't use the remote iPod control, and this was strange at a first look.
At the end my opinion is that they do the following:
Avoid the call to beginReceivingRemoteControlEvents which allows to activate the iPod controls while in background (in fact they don't have it)
In this way, the status bar doesn't show the play icon while
the app plays audio
When the app goes in background, it probably plays a no sound periodically (once every 10 secs for example), in this way the app remains active
I saw that they also avoided to manage interruptions, for example in case another app is in foreground and plays music. Again Apple should have rejected the app for that reason, cos it is against the rules to follow while in background, but maybe they didn't see it during the acceptance tests.
So my interpretation is that they have intentionally missed to activate the iPod controls, just to avoid to show the play icon in the status bar while in background. In this way, the users are unaware that the app is active and is doing something strange after they close it.
In addition you can see that the app doesn't interrupt when another app plays in foreground a sound or audio, because otherwise they risk that the app doesn't restart on time when the alarm shpould fire.
That's just my idea of how they do that, and I think this is the only way for an audio app on iOS to remain active while it is in background and is supposed to be halted (well, in case Apple doesn't see the trick).
Have you tried adding this to appdelegate.m
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
// Call your method in here.
}
if you have can you add code for us to see what your doing.

Resources