It is vital to have gained consent before providing first aid. Introduce yourself, tell them you are a first aider and ask if you can help them, if they say yes, then you obviously have their consent.
Most first aiders are trained to introduce themselves and say "I'm a first aider, may I help you?" you don't have to use this exact phrase but it is a good idea to have a "set way" of asking for consent, so that if asked you can easily recall how you gained consent.
It is important to maintain communication with a patient while providing first aid, tell them what you are going to do, why you need to do it and ask them if it is OK for you to do it. If you need to touch them, tell them what you need to do and why, ask them if it is OK. Keep them informed, consent is a continual process.
Consent can be implied, for example where a patient is unconscious, you must still introduce yourself and ask for their permission to help them, if they cannot reply it is assumed that they would want you to help, but you must still ask to rely on implied consent. If the patient becomes conscious you would need to ask them again for permission to help.
If a patient cannot respond verbally, for example if they are choking and cannot speak, they could nod to confirm their consent, if someone stretches out a hand to you this may also be deemed to be consenting.
If the patient is a child, ask the parent or guardian for consent, if the patient is an adult with a member of their family, ask them for consent.
Consent and implied consent are very important aspects in first aid, make sure that you always gain consent correctly in the first place and renew that consent continuously while you provide first aid.