Peel, core, then roughly chop the apples. Roughly chop the onions, finely chop the garlic and peel and finely chop the ginger.
Place the apple, onion, garlic, ginger, chilli flakes and fruit into a large, wide saucepan. Stir in the vinegar, sugar and salt. Stir the mixture over a medium heat until all the sugar has dissolved.
Once the sugar has dissolved, bring to the boil, then reduce the heat slightly and simmer the chutney for around one hour, stirring every so often. As it thickens, stir more frequently and watch that the sugar does not begin to stick to the bottom of the pan. The chutney is done when you can scrape a wooden spoon across the bottom of the pan and the chutney does not flow back into the gap.
Meanwhile, to clean the jam jars, preheat the oven to 140C/275F/Gas 1. Wash the jars well in warm soapy water then rinse thoroughly under running water. Leave the jars and lids to dry, upside down, in the oven. (Or you can clean the jars by putting them through the hot cycle of a dishwasher.)
Carefully spoon the chutney into the sterilised jars and seal while hot. Store in a cool, dark place for about a month before eating, to let the flavours mellow.