How to detect in Safari if the application is installed

I am trying to write a simple safari plugin that only needs to check if the application I developed is installed via javascript. The application is launched using a custom uri.

My problem is very similar to that presented here , however, I am not developing against iphone \ ipad, and all I really want is a true / false result from my check so that I can present the user with a link to "download the application" or "launch the application".

I already have a version of Windows that works using npruntime for firefox \ chrome and ATL for IE, which is described here

+3
source share
1 answer

Launch Services is the API you need. See the example below:

#include <ApplicationServices/ApplicationServices.h>

bool check_scheme_handler(CFStringRef scheme){
    CFStringRef handler=LSCopyDefaultHandlerForURLScheme(scheme);
    if(handler){
        CFShow(handler);
        CFRelease(handler);
        return true;
    }else{
        CFShow(CFSTR("not found"));
        return false;
    }
}

int main(){
    check_scheme_handler(CFSTR("http"));
    check_scheme_handler(CFSTR("bogus"));
    return 0;
}
0
source

Source: https://habr.com/ru/post/1769352/


All Articles