views:

32

answers:

1

I'm attempting to write a simple plugin in safari that only needs to check if an application 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

+1  A: 

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;
}
Yuji
Sorry to be a total noob but could you elaborate a bit more about the process of me implementing and utilizing this method? A point towards a useful tutorial or walkthrough would be greatly appreciated.
Amith
Well this is the way to detect if a URL scheme is supported or not. This code can be used either inside or outside of Safari plugin. The way to write a Safari/Firefox plugin would be a different question:p
Yuji