开发者

How to detect in Safari if an Application is Installed

I'm attempting to write a simple plugin in safari that only needs to check if an appl开发者_开发问答ication I have developed is installed via javascript. The application launches using a custom uri.

My issue is very similiar to the one presented here, however I'm not developing against iphone\ipad and all I really want is a true\false outcome from my check so that I can present the user with a 'download application or 'launch application' link.

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜