http agent irule

i want to make an irule that allow only ios & android only to access application can someone help me with that??

this code may detect all devices (Maybe you can search user-agent for AppleTV and Apple Watch). The ua variable contains the lowercase user-agent, so only search for lowercase string.

when HTTP_REQUEST {
    if {[set ua [string tolower [HTTP::header User-Agent]]] contains "iphone" || $ua contains "ipad" || $ua contains "android"} {
         This client is an iPhone, iPad or an Android device
    }
}

Note : code updated (a closing bracket was missing)