Hide/show a custom block
Plugin ID doesn't equal Block ID, example. 

isForbidden is not a static function, need to use forbidden.

if ($block-&gt;id() == 'downloadourapp') {

    // If the user's phone is Android.
    if(preg_match("/(android)/i", $_SERVER["HTTP_USER_AGENT"])) {

    return AccessResult::forbidden()-&gt;addCacheableDependency($block);

    }
}