4

I'm working on a Walkie Talkie app and have the basics working. You select a user, record a message which is then sent via push notification. They open the app which downloads and plays the message. I was pretty happy with it until I came across Zello.

They are doing 2 things of interest:

1) If you receive a message and the app is running in the background it will display a notification and begin playing the message without having to open the app.

Zello

2) The message is streamed to your phone and begins playback while the other user is still speaking.

Can anyone give me a clue as to how they're doing this? I've added the basics like setting the audio/voip background mode keys and initializing the audio session:

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];

But I'm unsure how to proceed beyond this.

marcdown
  • 194
  • 7

1 Answers1

1

Try this code in viewdidload method:

    NSError *setCategoryErr = nil;
    NSError *activationErr  = nil;
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr];
    [[AVAudioSession sharedInstance] setActive: YES error: &activationErr];
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    UIBackgroundTaskIdentifier newTaskId = UIBackgroundTaskInvalid;
    newTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];

Hope it helps you.

Vishal
  • 8,246
  • 6
  • 37
  • 52
  • Thanks for the code sample. I tried this but its still not working. I'm beginning to think sockets are involved. I'll keep digging. – marcdown Oct 06 '12 at 21:22
  • @marcdown are you able to solve the issue? In my case after receiving push notification I am able to connect socket and and then joined room and then webrtc stream is coming. But I can not hear the sound, because I am getting "AURemoteIO.cpp:1668 AUIOClient_StartIO failed (561145187)". I tried by setting only playback mode but none of them worked. – M. Paul Jan 04 '23 at 11:12