How to keep receiving the data when app is sent to background mode?How to change the name of an iOS app?How can I make a UITextField move up when the keyboard is present - on starting to edit?How do I get a background location update every n minutes in my iOS application?What happens if the user closes an app that is already in the background?Executing code while in background audio modeStarting audio streaming from a BLE event when in the backgroundWhy backgroundTimeRemaining gives DBL_MAX even if application state is UIApplicationStateBackground?my app media play in background mode didn't play if once I open apple music appiOS keep app living in the backgroundMultipeer Connectivity in background mode

Allocating credit card points

How can an attacker use robots.txt?

Is it a good idea to leave minor world details to the reader's imagination?

How can I repair this gas leak on my new range? Teflon tape isn't working

What is this utensil for?

How to ask a man to not take up more than one seat on public transport while avoiding conflict?

Does the Orange League not count as an official Pokemon League, making the Alolan League his first-ever win?

Does wetting a beer glass change the foam characteristics?

Why does NASA publish all the results/data it gets?

Is the mass of paint relevant in rocket design?

What is the meaning of word 'crack' in chapter 33 of A Game of Thrones?

Non-cadential use of 6/4 chord

What do you do if you have developments on your paper during the long peer review process?

Worms crawling under skin

Conditionally execute a command if a specific package is loaded

How to manage expenditure when billing cycles and paycheck cycles are not aligned?

How is the problem, G has no triangle in Logspace?

How much damage can be done just by heating matter?

Find missing number in the transformation

Can the U.S. president make military decisions without consulting anyone?

What can a pilot do if an air traffic controller is incapacitated?

Is it impolite to ask for halal food when traveling to and in Thailand?

Hiking with a mule or two?

Why is there is no screening for Ovarian Cancer?



How to keep receiving the data when app is sent to background mode?


How to change the name of an iOS app?How can I make a UITextField move up when the keyboard is present - on starting to edit?How do I get a background location update every n minutes in my iOS application?What happens if the user closes an app that is already in the background?Executing code while in background audio modeStarting audio streaming from a BLE event when in the backgroundWhy backgroundTimeRemaining gives DBL_MAX even if application state is UIApplicationStateBackground?my app media play in background mode didn't play if once I open apple music appiOS keep app living in the backgroundMultipeer Connectivity in background mode






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















In iOS12 apple started canceling network requests if they are not URLSessionDownloadTask and setup with background session.



But according to the apple website:




You don’t have to do all background network activity with background
sessions... Apps that declare appropriate
background modes can use default URL sessions and data tasks, just as
if they were in the foreground




I'm streaming media file with a custom player, application has Audio and Background Fetch modes enabled. URLSessionDataTask is initialized in foreground as soon as app enters background state task is canceled.



I'm aware that AVPlayer can stream in the background but using AVPlayer is not an option.



I'm aware that I can setup session with URLSessionDownloadTask which will download data in separate process and return path to file, which is not an option due the the streaming requirement.



I'm aware that I can request additional background execution time with UIApplication.shared.beginBackgroundTask but it's not acceptable solution because if backgroundTimeRemaining expires before stream finished app will be killed.



Is there any way to keep receiving data when app is in the background mode?










share|improve this question


























  • Are you 100% sure that your “custom player” is keeping the app running in the background and that the app isn’t being suspended?

    – Rob
    Mar 28 at 16:43











  • yes. It plays for as long as there data in the buffer, after that it stops.

    – Digitech
    Mar 28 at 18:25

















2















In iOS12 apple started canceling network requests if they are not URLSessionDownloadTask and setup with background session.



But according to the apple website:




You don’t have to do all background network activity with background
sessions... Apps that declare appropriate
background modes can use default URL sessions and data tasks, just as
if they were in the foreground




I'm streaming media file with a custom player, application has Audio and Background Fetch modes enabled. URLSessionDataTask is initialized in foreground as soon as app enters background state task is canceled.



I'm aware that AVPlayer can stream in the background but using AVPlayer is not an option.



I'm aware that I can setup session with URLSessionDownloadTask which will download data in separate process and return path to file, which is not an option due the the streaming requirement.



I'm aware that I can request additional background execution time with UIApplication.shared.beginBackgroundTask but it's not acceptable solution because if backgroundTimeRemaining expires before stream finished app will be killed.



Is there any way to keep receiving data when app is in the background mode?










share|improve this question


























  • Are you 100% sure that your “custom player” is keeping the app running in the background and that the app isn’t being suspended?

    – Rob
    Mar 28 at 16:43











  • yes. It plays for as long as there data in the buffer, after that it stops.

    – Digitech
    Mar 28 at 18:25













2












2








2


1






In iOS12 apple started canceling network requests if they are not URLSessionDownloadTask and setup with background session.



But according to the apple website:




You don’t have to do all background network activity with background
sessions... Apps that declare appropriate
background modes can use default URL sessions and data tasks, just as
if they were in the foreground




I'm streaming media file with a custom player, application has Audio and Background Fetch modes enabled. URLSessionDataTask is initialized in foreground as soon as app enters background state task is canceled.



I'm aware that AVPlayer can stream in the background but using AVPlayer is not an option.



I'm aware that I can setup session with URLSessionDownloadTask which will download data in separate process and return path to file, which is not an option due the the streaming requirement.



I'm aware that I can request additional background execution time with UIApplication.shared.beginBackgroundTask but it's not acceptable solution because if backgroundTimeRemaining expires before stream finished app will be killed.



Is there any way to keep receiving data when app is in the background mode?










share|improve this question
















In iOS12 apple started canceling network requests if they are not URLSessionDownloadTask and setup with background session.



But according to the apple website:




You don’t have to do all background network activity with background
sessions... Apps that declare appropriate
background modes can use default URL sessions and data tasks, just as
if they were in the foreground




I'm streaming media file with a custom player, application has Audio and Background Fetch modes enabled. URLSessionDataTask is initialized in foreground as soon as app enters background state task is canceled.



I'm aware that AVPlayer can stream in the background but using AVPlayer is not an option.



I'm aware that I can setup session with URLSessionDownloadTask which will download data in separate process and return path to file, which is not an option due the the streaming requirement.



I'm aware that I can request additional background execution time with UIApplication.shared.beginBackgroundTask but it's not acceptable solution because if backgroundTimeRemaining expires before stream finished app will be killed.



Is there any way to keep receiving data when app is in the background mode?







ios






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 21:54









rmaddy

261k29 gold badges358 silver badges421 bronze badges




261k29 gold badges358 silver badges421 bronze badges










asked Mar 28 at 15:51









DigitechDigitech

1828 bronze badges




1828 bronze badges















  • Are you 100% sure that your “custom player” is keeping the app running in the background and that the app isn’t being suspended?

    – Rob
    Mar 28 at 16:43











  • yes. It plays for as long as there data in the buffer, after that it stops.

    – Digitech
    Mar 28 at 18:25

















  • Are you 100% sure that your “custom player” is keeping the app running in the background and that the app isn’t being suspended?

    – Rob
    Mar 28 at 16:43











  • yes. It plays for as long as there data in the buffer, after that it stops.

    – Digitech
    Mar 28 at 18:25
















Are you 100% sure that your “custom player” is keeping the app running in the background and that the app isn’t being suspended?

– Rob
Mar 28 at 16:43





Are you 100% sure that your “custom player” is keeping the app running in the background and that the app isn’t being suspended?

– Rob
Mar 28 at 16:43













yes. It plays for as long as there data in the buffer, after that it stops.

– Digitech
Mar 28 at 18:25





yes. It plays for as long as there data in the buffer, after that it stops.

– Digitech
Mar 28 at 18:25












1 Answer
1






active

oldest

votes


















0
















Make sure your background session has shouldUseExtendedBackgroundIdleMode enabled. If you don’t, the session will stop data tasks when the app transitions from foreground execution to background execution. Or, as that Downloading Files in the Background document says, you can use default session configurations, too, which don’t exhibit this behavior.




FWIW, when using AVPlayer, in addition to enabling background audio capability ...



enter image description here



... you may also have to tell the shared audio session instance that it’s active:



try AVAudioSession.sharedInstance().setCategory(.playback)
try AVAudioSession.sharedInstance().setActive(true)


I can’t say what your “custom player” requires, but for me I had to do both of these to keep the app running in the background, playing audio, with AVPlayer.






share|improve this answer

























  • Tested with shouldUseExtendedBackgroundIdleMode set to true, it keeps connection alive while app in the background state (but it looks like download is paused), as soon as device is locked connection is cancelled. I'm aware that when using AVPlayer system keeps connection alive, I'm suspecting that AVPlayer has special permissions. Here is the link to test project, if you'd like to check project setup / see described behavior. dropbox.com/s/iljpunkkzi47t4l/DataTaskExample.zip

    – Digitech
    Mar 31 at 4:30













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55401888%2fhow-to-keep-receiving-the-data-when-app-is-sent-to-background-mode%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0
















Make sure your background session has shouldUseExtendedBackgroundIdleMode enabled. If you don’t, the session will stop data tasks when the app transitions from foreground execution to background execution. Or, as that Downloading Files in the Background document says, you can use default session configurations, too, which don’t exhibit this behavior.




FWIW, when using AVPlayer, in addition to enabling background audio capability ...



enter image description here



... you may also have to tell the shared audio session instance that it’s active:



try AVAudioSession.sharedInstance().setCategory(.playback)
try AVAudioSession.sharedInstance().setActive(true)


I can’t say what your “custom player” requires, but for me I had to do both of these to keep the app running in the background, playing audio, with AVPlayer.






share|improve this answer

























  • Tested with shouldUseExtendedBackgroundIdleMode set to true, it keeps connection alive while app in the background state (but it looks like download is paused), as soon as device is locked connection is cancelled. I'm aware that when using AVPlayer system keeps connection alive, I'm suspecting that AVPlayer has special permissions. Here is the link to test project, if you'd like to check project setup / see described behavior. dropbox.com/s/iljpunkkzi47t4l/DataTaskExample.zip

    – Digitech
    Mar 31 at 4:30















0
















Make sure your background session has shouldUseExtendedBackgroundIdleMode enabled. If you don’t, the session will stop data tasks when the app transitions from foreground execution to background execution. Or, as that Downloading Files in the Background document says, you can use default session configurations, too, which don’t exhibit this behavior.




FWIW, when using AVPlayer, in addition to enabling background audio capability ...



enter image description here



... you may also have to tell the shared audio session instance that it’s active:



try AVAudioSession.sharedInstance().setCategory(.playback)
try AVAudioSession.sharedInstance().setActive(true)


I can’t say what your “custom player” requires, but for me I had to do both of these to keep the app running in the background, playing audio, with AVPlayer.






share|improve this answer

























  • Tested with shouldUseExtendedBackgroundIdleMode set to true, it keeps connection alive while app in the background state (but it looks like download is paused), as soon as device is locked connection is cancelled. I'm aware that when using AVPlayer system keeps connection alive, I'm suspecting that AVPlayer has special permissions. Here is the link to test project, if you'd like to check project setup / see described behavior. dropbox.com/s/iljpunkkzi47t4l/DataTaskExample.zip

    – Digitech
    Mar 31 at 4:30













0














0










0









Make sure your background session has shouldUseExtendedBackgroundIdleMode enabled. If you don’t, the session will stop data tasks when the app transitions from foreground execution to background execution. Or, as that Downloading Files in the Background document says, you can use default session configurations, too, which don’t exhibit this behavior.




FWIW, when using AVPlayer, in addition to enabling background audio capability ...



enter image description here



... you may also have to tell the shared audio session instance that it’s active:



try AVAudioSession.sharedInstance().setCategory(.playback)
try AVAudioSession.sharedInstance().setActive(true)


I can’t say what your “custom player” requires, but for me I had to do both of these to keep the app running in the background, playing audio, with AVPlayer.






share|improve this answer













Make sure your background session has shouldUseExtendedBackgroundIdleMode enabled. If you don’t, the session will stop data tasks when the app transitions from foreground execution to background execution. Or, as that Downloading Files in the Background document says, you can use default session configurations, too, which don’t exhibit this behavior.




FWIW, when using AVPlayer, in addition to enabling background audio capability ...



enter image description here



... you may also have to tell the shared audio session instance that it’s active:



try AVAudioSession.sharedInstance().setCategory(.playback)
try AVAudioSession.sharedInstance().setActive(true)


I can’t say what your “custom player” requires, but for me I had to do both of these to keep the app running in the background, playing audio, with AVPlayer.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 28 at 23:38









RobRob

322k53 gold badges604 silver badges780 bronze badges




322k53 gold badges604 silver badges780 bronze badges















  • Tested with shouldUseExtendedBackgroundIdleMode set to true, it keeps connection alive while app in the background state (but it looks like download is paused), as soon as device is locked connection is cancelled. I'm aware that when using AVPlayer system keeps connection alive, I'm suspecting that AVPlayer has special permissions. Here is the link to test project, if you'd like to check project setup / see described behavior. dropbox.com/s/iljpunkkzi47t4l/DataTaskExample.zip

    – Digitech
    Mar 31 at 4:30

















  • Tested with shouldUseExtendedBackgroundIdleMode set to true, it keeps connection alive while app in the background state (but it looks like download is paused), as soon as device is locked connection is cancelled. I'm aware that when using AVPlayer system keeps connection alive, I'm suspecting that AVPlayer has special permissions. Here is the link to test project, if you'd like to check project setup / see described behavior. dropbox.com/s/iljpunkkzi47t4l/DataTaskExample.zip

    – Digitech
    Mar 31 at 4:30
















Tested with shouldUseExtendedBackgroundIdleMode set to true, it keeps connection alive while app in the background state (but it looks like download is paused), as soon as device is locked connection is cancelled. I'm aware that when using AVPlayer system keeps connection alive, I'm suspecting that AVPlayer has special permissions. Here is the link to test project, if you'd like to check project setup / see described behavior. dropbox.com/s/iljpunkkzi47t4l/DataTaskExample.zip

– Digitech
Mar 31 at 4:30





Tested with shouldUseExtendedBackgroundIdleMode set to true, it keeps connection alive while app in the background state (but it looks like download is paused), as soon as device is locked connection is cancelled. I'm aware that when using AVPlayer system keeps connection alive, I'm suspecting that AVPlayer has special permissions. Here is the link to test project, if you'd like to check project setup / see described behavior. dropbox.com/s/iljpunkkzi47t4l/DataTaskExample.zip

– Digitech
Mar 31 at 4:30




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55401888%2fhow-to-keep-receiving-the-data-when-app-is-sent-to-background-mode%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현