iOS stream audio when local notification fire
Asked Answered
E

0

0

I am creating Radio application in swift.

Application have list of radio station. When user click on any station they will play radio in foreground as well as background.

Now I have requirement that when user select any radio from list then he can able to add that radio in Playlist. When user select radio for playlist he will be ask for date and time to play selected radio automatically.

Let's say User selected "Radio1" for 10.00 am Monday. Now that radio will be play on every Monday at 10.00 am automatically whether app is on foreground or background.

I tried above task using Local notification. I made function that will play radio when notification fire. But the issue is that Radio is playing when app is in foreground.

My question is how can I call the function when app is on background and notification fire?

If anyone have other idea that how can I achieve this task then please guide me.

Thanks, Ekta

Elect answered 19/3, 2018 at 6:42 Comment(5)
By using Notification extension you can process data within 30 sec. But after 30 sec you can't process anything. If your app is in foreground you can play radio as per your requirement. But in background iOS will not allow to process data more than 30 secJob
@GaneshManickam I want to stream when app is in backgroundElect
@EktaPadaliya as we were discussing here: https://mcmap.net/q/138081/-ios-10-unusernotificationcenterdelegate-not-called-push-notifications-not-working I don't think Apple would approve your app even if you did get it to work. Sorry. Apple wants users to physically interact with a device if it's going to start playing audio (longer than an alert). For the same reason alerts can only play very short sounds.Forcer
@DaveWood Thanks for your suggestion. So I have to do interactive notification and when user select play then radio will be play. Right?Elect
@EktaPadaliya Yes, that sounds like a better user experience.Forcer

© 2022 - 2024 — McMap. All rights reserved.