background-process

Unable to schedule a task from within a UNNotificationServiceExtension - Error: BGTaskSchedulerErrorDomain error 1

こ雲淡風輕ζ 提交于 2021-01-28 12:56:50
问题 As the title states, i am currently unable to schedule a task from within a UNNotificationServiceExtension. I would like to schedule the task when the following function is called and thus a push is received: func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) Currently as soon as i call: try BGTaskScheduler.shared.submit(request) The catch clause is entered and the following error is returned: 'The operation couldn’t

stop audio while in background

谁都会走 提交于 2021-01-27 14:40:29
问题 There is an app called IHeartRadio which lets you set a sleep timer which will shut off audio after a specified interval. You first choose a station to listen to and then select an amount of time to sleep after which the radio station will stop playing. The app does not need to be in the foreground for this to happen. How is it possible for an app to stop audio while it is in the background? One theory was to set a UILocalNotification with silent audio. Then the UILocalNotification would take

How to keep a service alive using AlarmManager.setInexactRepeating()?

廉价感情. 提交于 2020-08-10 08:26:09
问题 I have some existing code that spawns a service intent which does a bunch of stuff in the background. This code does work... Intent serviceIntent = new Intent(context, APMService.class); serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startService(serviceIntent); My question is: how to change this to use the AlarmManager.setInexactRepeating(...) methods? I have changed the above code to this: Intent serviceIntent = new Intent(context, APMService.class); serviceIntent.putExtra(