Developers
Import Int’ OnSong
Usin’ URL schemes ye can open other apps as long as ye know how t’ structure th’ URL. In addition, ye can open OnSong usin’ th’ UIDocumentInteractionController when ye pass a file type that th’ OnSong® can open. Arrr!
Website Link
One challenge with openin’ content into apps be knowin’ if th’ app be available. T’ solve this, we have created an import endpoint on th’ onsongapp.com website. Ye can make a sample link with th’ followin’ directions, matey:
- Ahoy! Visit onsongapp.com/import fer an easy way t’ generate th’ link.
- Enter th’ web address o’ th’ file ye want t’ import into th’ OnSong® an’ submit, savvy?
- Th’ system will attempt t’ retrieve information from th’ web usin’ an HTTP HEAD method t’ acquire th’ filename an’ size.
- If a HEAD operation be not supported on th’ content, it’ll derive th’ file type an’ file name from th’ URL.
- Ye will get a preview o’ th’ link with th’ ability t’ copy th’ link, which be easy t’ programmatically create. Arrr!
URL Scheme
Ye can use an URL on an iOS device t’ open OnSong an’ perform import functions. Th’ followin’ URL can be entered into th’ location bar o’ Safari t’ have iOS open th’ OnSong app. Avast!
If ye be openin’ th’ OnSong® app from another app, ye will need t’ add th’ onsong: schema t’ yer device’s list o’ approved schemas, ye scallywag.
onsong://
If ye want t’ open OnSong from an iOS app, ye can combine th’ followin’ Objective-C statements t’ determine if th’ user has OnSong installed, an’ if so, open OnSong from within yer app.
// See if the user has OnSong installed
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"onsong://"]]) {
// Open OnSong from your app
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"onsong://"]];
}
If ye would like t’ import a supported file format stored on yer website, replace th’ http:// component o’ th’ URL with onsong:// t’ open OnSong an’ prompt th’ user t’ import th’ file. If ye use SSL, ye will need t’ issue a redirect t’ th’ https:// location o’ th’ file since OnSong will resolve t’ th’ http:// location first. Blimey!
onsong://my.domain.com/files/go/here/Song%20Title.txt
In some cases ye may not have th’ file available on a web server. For instance, ye may want t’ generate th’ file within an app an’ then pass it t’ OnSong without first savin’ it t’ a publicly accessible location. Likewise, ye may want t’ secure th’ delivery o’ content since it be only available fer authenticated users. Fer those purposes, OnSong can also import files usin’ a Base64-encoded file usin’ th’ followin’ syntax such as this, matey:
onsong://ImportData/My%20Song%20Title.pdf?BASE_64_ENCODED_DATA_HERE
As an example, click on th’ followin’ link t’ import Welcome To OnSong as a PDF file, matey.
OnSong uses th’ file extension that be passed t’ it t’ determine how t’ treat each type o’ file. If ye be dynamically generatin’ content, ye’ll want t’ send a filename by settin’ a Content-Disposition HTTP header, savvy?