Last active
June 25, 2019 02:23
-
-
Save azamsharp/563ae035f6b9afffc14fa92c2459955f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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