-2

Can an app go into background execution and minimize itself, but execute a code to perform a certain action (recording the screen to be specific) in iOS Swift.

S S
  • 55
  • 11

1 Answers1

1

Programming Guide: Background Execution

This should help get you started. But you can't do what you want to do for longer than three minutes and you won't be able to put in on the app store.

Asdrubal
  • 2,421
  • 4
  • 29
  • 37
  • Thanks for the link Asdrubal... I want to create the .ipa file of it. But just to know why cant I publish the app in the app store. Is it because I am recording the screen – S S Jul 12 '16 at 13:48
  • You can do what you want, but it will only last for 3 minutes. You can't put it on the app store because it against the apple guidelines. I assume the reason for that guideline is that it waste battery. They do allow operations to occur in the background if they fit the criteria for example Navigation. – Asdrubal Jul 12 '16 at 14:15
  • Ok..Thanks for these infos. But incase I want to run the app in background. Can I self minimize the app and display the home screen instead ? – S S Jul 12 '16 at 14:30
  • http://stackoverflow.com/questions/14391784/how-to-minimize-an-ios-app?noredirect=1&lq=1 – Asdrubal Jul 12 '16 at 14:34
  • In the first case...does minimizing the app automatically takes it to background. Or it can still be kept in foreground ? – S S Jul 12 '16 at 14:54
  • It would enter the background and you would call your background execution code. But the easiest thing would be to indicate to your users to press the home button. – Asdrubal Jul 12 '16 at 14:56
  • If you think this was helpful I would appreciate being marked the answer – Asdrubal Jul 12 '16 at 14:58
  • I want to minimize the app, and show an alert to let user know that they are being taken to the home screen...And in the meantime run a part of my code which records the user actions on the screen thereon. – S S Jul 12 '16 at 15:03
  • You can't really do that directly. You can show an alert and in the alert message you can tell the user to press the home button. And when they press the home button the app will enter the background and then you can run your code. You won't be able to enter the background mode programmatically. – Asdrubal Jul 12 '16 at 15:06
  • Okk..Atleast I have got something to try upon.. Let me work on it. Thnks fr d help Asdrubal. – S S Jul 12 '16 at 15:10
  • No problem. Good luck :) – Asdrubal Jul 12 '16 at 15:10