• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Bluetooth Background Mode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Bluetooth Background Mode


  • Subject: RE: Bluetooth Background Mode
  • From: Joakim Fernstad <email@hidden>
  • Date: Fri, 23 Aug 2013 17:03:18 +0000
  • Thread-topic: Bluetooth Background Mode

No and Yes, bluetooth-central background mode is just for you to handle Bluetooth callbacks. It won’t give you time to execute other code.

 

For that you need to ask the OS for time to execute. Like this.

 

    __block UIBackgroundTaskIdentifier task = nil;

   

    // Ask application for time to execute code in the background

    task = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{

 

        // This will be called if you don’t call endBackgroundTask in some time

   // (~10 min is the popular opinion)

        // Clean up your state here.

        // If you don’t call endBackgroundTask here you app will be terminated

 

        [[UIApplication sharedApplication] endBackgroundTask:task];

    }];

 

 

       // execute your code to record audio

 

       // Release the background task.

        [[UIApplication sharedApplication] endBackgroundTask:task];

 

 

There is no guarantee that your code will get enough time to execute in the background. Write your code to handle that gracefully.

 

Note that this code should always be called when you want to record your audio since you never know when the app will enter background mode.

 

Regards,

 

Joakim

 

From: bluetooth-dev-bounces+jfernstad=email@hidden [mailto:bluetooth-dev-bounces+jfernstad=email@hidden] On Behalf Of Javaid, Bilal
Sent: Friday, August 23, 2013 9:53 AM
To: email@hidden
Subject: Bluetooth Background Mode

 

I understand that I can use bluetooth-central background mode to maintain a connection and handle bluetooth events in the background.

 

This has been working, but I would like to turn on the microphone and start listening for 1 minute when the App receives a particular bluetooth event, in the background.

 

I have tried this with the OpenEars Framework, and it works in the foreground, but it stops listening when the App enters the background. And if I try to start listening while in the background, I get an error from AudioSession.

 

So I am wondering if this should even be possible? Or do bluetooth-central permissions not allow this to happen?

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Bluetooth Background Mode (From: "Javaid, Bilal" <email@hidden>)

  • Prev by Date: Bluetooth Background Mode
  • Next by Date: Re: BLE connection to device on iOS 7 only partially succeeds
  • Previous by thread: Bluetooth Background Mode
  • Next by thread: Does BLE scanning get scaled back wrt battery power?
  • Index(es):
    • Date
    • Thread