-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from TortugaPower/feature/siri-shortcut
Siri shortcut for last played book
- Loading branch information
Showing
10 changed files
with
131 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// UserActivityManager.swift | ||
// BookPlayer | ||
// | ||
// Created by Gianni Carlo on 10/29/18. | ||
// Copyright © 2018 Tortuga Power. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Intents | ||
|
||
class UserActivityManager { | ||
static let shared = UserActivityManager() | ||
private init() {} | ||
|
||
var currentActivity: NSUserActivity? | ||
|
||
private func createPlaybackActivity() -> NSUserActivity { | ||
let activity = NSUserActivity(activityType: Constants.UserActivityPlayback) | ||
activity.title = "Continue last played book" | ||
if #available(iOS 12.0, *) { | ||
activity.isEligibleForPrediction = true | ||
activity.persistentIdentifier = NSUserActivityPersistentIdentifier(Constants.UserActivityPlayback) | ||
activity.suggestedInvocationPhrase = "Continue my book" | ||
} | ||
activity.isEligibleForSearch = true | ||
|
||
return activity | ||
} | ||
|
||
func resumePlaybackActivity() { | ||
self.currentActivity = self.currentActivity ?? self.createPlaybackActivity() | ||
self.currentActivity?.becomeCurrent() | ||
} | ||
|
||
func stopPlaybackActivity() { | ||
self.currentActivity?.resignCurrent() | ||
} | ||
} |