Skip to content

Commit

Permalink
Merge pull request #270 from TortugaPower/feature/url-scheme
Browse files Browse the repository at this point in the history
Add url scheme bookplayer://
  • Loading branch information
GianniCarlo authored Nov 3, 2018
2 parents 32cf4f5 + d9a9bed commit 4afdc89
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 12 additions & 2 deletions BookPlayer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

// Handles audio file urls, like when receiving files through AirDrop
// Also handles custom URL scheme 'bookplayer://'
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
// This function is called when the app is opened with a audio file url,
// like when receiving files through AirDrop
guard url.isFileURL else {
if PlayerManager.shared.isLoaded {
PlayerManager.shared.play()
} else {
UserDefaults.standard.set(true, forKey: Constants.UserActivityPlayback)
}

return true
}

DataManager.processFile(at: url)

return true
Expand Down
13 changes: 13 additions & 0 deletions BookPlayer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@
<string>3.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>bookplayer</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand Down

0 comments on commit 4afdc89

Please sign in to comment.