Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Last active June 25, 2019 02:23
Show Gist options
  • Save azamsharp/563ae035f6b9afffc14fa92c2459955f to your computer and use it in GitHub Desktop.
Save azamsharp/563ae035f6b9afffc14fa92c2459955f to your computer and use it in GitHub Desktop.
import Foundation
import UIKit
import Intents
import CoreSpotlight
import CoreServices
@IBAction func donate() {
// perform an actual order here
// donating the activity to Siri
let orderActivity = NSUserActivity(activityType: "com.azamsharp.HotCoffee.hot-coffee-activity-type")
orderActivity.isEligibleForSearch = true
orderActivity.isEligibleForPrediction = true
orderActivity.title = "Regular Hot Coffee"
orderActivity.suggestedInvocationPhrase = "Coffee Time"
orderActivity.userInfo = ["Key":"Value"]
let attributes = CSSearchableItemAttributeSet(itemContentType: kUTTypeItem as String)
attributes.contentDescription = "Get it while its hot!"
attributes.thumbnailData = UIImage(named: "pp-hot-coffee-rf-istock.jpg")?.pngData()
orderActivity.contentAttributeSet = attributes
self.userActivity = orderActivity
self.userActivity?.becomeCurrent()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment