splinesoft / SSAppURLs

Quickly check for and open URLs using iOS app URL schemes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SSAppURLs

Circle CI Coverage Status

Quickly check for and open URLs using iOS app URL schemes.

SSAppURLs is a tiny UIApplication category that makes it easy to:

  • Check if the current device has an app installed (e.g. Skype)
  • Check if the current device has certain capabilities (e.g. FaceTime)
  • Open an app with a URL scheme and pass some arguments

SSAppURLs, along with SSPreferredBrowser, powers various URL actions and open-in-browser behavior in my app MUDRammer - A Modern MUD Client for iPhone and iPad.

Install

Install with CocoaPods. Add to your Podfile:

pod 'SSAppURLs', :head # YOLO

Examples

Check out Example for an app example.

#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"];
}

Thanks!

SSAppURLs is a @jhersh production -- (electronic mail | @jhersh)

About

Quickly check for and open URLs using iOS app URL schemes.

License:MIT License


Languages

Language:Objective-C 94.7%Language:Ruby 5.3%