Developers

Import Into OnSong

Using URL schemes you can open other apps as long as you know how to structure the URL. In addition, you can open OnSong using the UIDocumentInteractionController when you pass a file type that the OnSong® can open.

Website Link

One challenge with opening content into apps is knowing if the app is available. To solve this, we have created an import endpoint on the onsongapp.com website. You can make a sample link with the following directions:

  • Visit onsongapp.com/import for an easy way to generate the link.
  • Enter the web address of the file you want to import into the OnSong® and submit.
  • The system will attempt to retrieve information from the web using an HTTP HEAD method to acquire the filename and size.
  • If a HEAD operation is not supported on the content, it will derive the file type and file name from the URL.
  • You will get a preview of the link with the ability to copy the link which is easy to programatically create.

URL Scheme

You can use an URL on an iOS device to open OnSong and perform import functions. The following URL can be entered into the location bar of Safari to have iOS open the OnSong app.

If you are opening the OnSong® app from another app, you will need to add the onsong: schema to you're device's list of approved schemas.

onsong://

If you want to open OnSong from an iOS app, you can combine the following Objective-C statements to determine if the user has OnSong installed, and if so, open OnSong from within your 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 you would like to import a supported file format stored on your website, replace the http:// component of the URL with onsong:// to open OnSong and prompt the user to import the file. If you use SSL, you will need to issue a redirect to the https:// location of the file since OnSong will resolve to the http:// location first.

onsong://my.domain.com/files/go/here/Song%20Title.txt

In some cases you may not have the file available on a web server. For instance, you may want to generate the file within an app and then pass it to OnSong without first saving it to a publicly accessible location. Likewise, you may want to secure the delivery of content since it is only available for authenticated users. For those purposes, OnSong can also import files using a Base64-encoded file using the following syntax such as this:

onsong://ImportData/My%20Song%20Title.pdf?BASE_64_ENCODED_DATA_HERE

As an example, click on the following link to import Welcome To OnSong as a PDF file.

OnSong uses the file extension that is passed to it to determine how to treat each type of file. If you are dynamically generating content, you'll want to send a filename by setting a Content-Disposition HTTP header.