Adding the background fetch capability

Every application has a list of capabilities they can opt in to. Some examples of these capabilities are using Maps, HomeKit, and Background Modes. You can find the Capabilities tab in your project settings. If you select your project in the file navigator, you can see the Capabilities tab right next to your app's General settings.

If you select this tab, you will see a list of all the capabilities your app can implement. If you expand a capability, you'll find some information about what the capability does and what happens automatically if you enable it. If you expand the Background Modes capability, you'll see the following information:

There are several options that you can enable, but there's just one that you need to focus on for now. The capability you need to enable is Background Fetch. Click the on/off checkbox to enable the capability and then check the Background Fetch option.

Enabling Background Fetch isn't something that magically changes some invisible settings for your application. You can enable background fetch manually if you'd like to.

Open the Info.plist file and search for the Required background modes key. You can see that it contains a single item with a value of App downloads content from the network. This entry in the Info.plist file enables your app to ask iOS to wake it up periodically:

However, just because you can do this manually does not mean you should. The capabilities tab is a very convenient place to manage capabilities from and manually adding the right key to the Info.plist file is tedious and error-prone. It's interesting to know that there's no magic involved in this process, and it makes the entire feature feel more transparent.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.140.206