iOS equivalent to Android Service?

前端 未结 4 1750
庸人自扰
庸人自扰 2020-12-09 22:14

So with iOS 7 supporting a broader background mode, is it possible to finally have an equivalent to Android Service on iOS?

What I am after is essentially running ap

4条回答
  •  [愿得一人]
    2020-12-09 22:56

    I found the best and standard solution:

    Push notifications

    (original post by Matthijs Hollemans, update by Ali Hafizji).

    In iOS, apps can’t do a lot in the background. Apps are only allowed to do limited set of activities so battery life is conserved. But what if something interesting happens and you wish to let the user know about this, even if they’re not currently using your app? For example, maybe the user received a new tweet, their favorite team won the game, or their dinner is ready. Since the app isn’t currently running, it cannot check for these events. Luckily, Apple has provided a solution to this. Instead of your app continuously checking for events or doing work in the background, you can write a server-side component to do this instead. And when an event of interest occurs, the server-side component can send the app a push notification! There are three things a push notification can do:

    • Display a short text message
    • Play a brief sound
    • Set a number in a badge on the app’s icon

    Tutorial link: http://maniacdev.com/2011/05/tutorial-ios-push-notification-services-for-beginners

提交回复
热议问题