1import { ConfigPlugin, createRunOncePlugin, withInfoPlist } from 'expo/config-plugins';
2
3const pkg = require('expo-task-manager/package.json');
4
5const withTaskManager: ConfigPlugin = (config) => {
6  config = withInfoPlist(config, (config) => {
7    if (!Array.isArray(config.modResults.UIBackgroundModes)) {
8      config.modResults.UIBackgroundModes = [];
9    }
10    if (!config.modResults.UIBackgroundModes.includes('fetch')) {
11      config.modResults.UIBackgroundModes.push('fetch');
12    }
13    return config;
14  });
15
16  return config;
17};
18
19export default createRunOncePlugin(withTaskManager, pkg.name, pkg.version);
20