Reputation: 679
I have a Swift 3 iOS10 app with a Siri Payment Intent Extension. Is there a way to prompt the user for the Siri App Support permission (Found in Settings -> Siri -> App Support -> (Your app name)) within the main app. You can do something similar for other permissions (like push notifications). The only way I've found to enable this switch is to actually try to use the intent for the first time by saying something like "Pay (Your App Name)" which triggers the payment intent. I'd like to have a Settings screen within the main app to give the users a tutorial on how it works and the option to enable it.
Upvotes: 0
Views: 2670
Reputation: 662
It seems you can now prompt for user authorisation, for instance in the AppDelegate, as mentioned here:
Then, in application(_: didFinishLaunchingWithOptions:) add the following code.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. INPreferences.requestSiriAuthorization { (authStatus: INSiriAuthorizationStatus) in } return true }
Upvotes: 0
Reputation: 679
Users must grant permission for your app to use SiriKit. To request permission for your app, do the following:
Include the NSSiriUsageDescription key in your iOS app’s Info.plist file. The value for this key is a string that describes what information your app shares with SiriKit. For example, a workout app might set the value to the string “Workout information will be sent to Siri.” Call the requestSiriAuthorization: class method of INPreferences at some point during your app’s execution. The first time that your iOS app calls the requestSiriAuthorization: method, the system displays an alert that prompts the user to authorize your app. The alert includes the usage description string you provided in the NSSiriUsageDescription key of your app’s Info.plist file. The user can approve or deny your app’s request for authorization and can change your app’s authorization status later in the Settings app. The system remembers your app’s authorization status so that subsequent calls to the requestSiriAuthorization: method do not prompt the user again.
Upvotes: 1