SSAppURLs本地设备 App 检测
SSAppURLs 可以根据 URL scheme 来检测本地设备是否装有某个 App,并且可以打开某个 App,可以传递参数。比如打开 Safari 或者 Chrome 浏览器,可以传递要打开的网址。
示例代码:
#import <UIApplication+SSAppURLs.h> // Does the current device have skype installed? BOOL deviceSupportsSkype = [[UIApplication sharedApplication] canOpenAppType:SSAppURLTypeSkype]; // If so, let's make a call! if( deviceSupportsSkype ) [[UIApplication sharedApplication] openAppType:SSAppURLTypeSkype withValue:@"415-555-1212"]; // Does the current device have Chrome installed? BOOL deviceHasChrome = [[UIApplication sharedApplication] canOpenAppType:SSAppURLTypeChromeHTTP]; // If so, open a website in chrome! if( deviceHasChrome ) [[UIApplication sharedApplication] openAppType:SSAppURLTypeChromeHTTP withValue:@"http://www.splinesoft.net"]; // Check for an arbitrary scheme type BOOL deviceHasTelnetApp = [[UIApplication sharedApplication] canOpenAppWithScheme:@"telnet"]; // Let's play NANVAENT! if( deviceHasTelnetApp ) [[UIApplication sharedApplication] openAppWithScheme:@"telnet" withValue:@"nanvaent.org:23"];
评论