I've created a custom Siri Intent. It is visible in the "Shortcuts" app. However, it allows me to pick only from donated shortcuts, without an option to specify own parameter.
Is it possible to create a Siri Intent that supports providing parameters using the "Shortcuts" app?
My Intents configuration
How the result looks like:
What I'd like to achieve
Notice, how the fields could be pre-filed (e.g. Item field). I'd like to have the same option for the phoneNumber.
EDIT
Parameters are now supported in iOS13. Documentation
Old Answer
As for now (iOS12), that doesn't work. The values for all custom parameters have to be known when you donate the Shortcut. From the documentation:
To donate the intent, create an instance of the intent class. Set its parameter values and add images to the parameters as needed.
To make it clear: A Siri Shortcut is really just a shortcut in the means of that it combines a series of fixed steps into a single button press. Think of it like a Amazon Dash Button. These buttons let you order a specific product with a button press. Say the button was created to order your favorite chocolate chip cookies from company A. So each time you press it, you order another pack of chocolate chip cookies from company A and only that. It doesn't take in any parameters during the press. So if your taste changes and you now want to order chocolate cranberry cookies from company A, you would need to replace your dash button.
As for the screenshot above. The shortcuts you see in the Shortcuts app with parameters are created by the Shortcuts team and use the URL scheme of certain apps. We can only hope that they open it up in iOS13.
Related
There are a dozen related actions that users of my app can perform, and I'd like to let them do it with Siri, but I'm unsure how to effectively do that. I know I can donate a INIntent when a user performs an action, but is it possible to donate an action with a customizable parameter? The user could, for example say "Perform action 1", 1 being the parameter. Would the user have to perform each of the 12 actions before they could do that with Siri? I also know it's possible to use NSUserActivity and INInteractions to make it easier for users to use Siri with an app, but I can't find any resources that will let me know if what I want to do is at all possible...
It is not possible to have a variable parameter. Siri shortcuts are for actions, which are executed by the user, so all needed information should be available when donated.
If you want to perform actions with different parameters, you have to donate for each of these actions.
You can also check this post in the apple developer forum about the same problem:
https://forums.developer.apple.com/message/326487#326487
I'm planning to use both NSUserActivity and CoreSpotlight on my app at the same time, but somehow I can't make it work as I intended.
I'm currently working in a retailer online shop.
The following steps would be required:
Step 1. Every product the user visited in my iPhone app, will get identified by a NSUserActivity object which will be shown in Search API. Also, it's public and has a thumbnail image, title, description and expiry date.
Step 2. The user searches on the iPhone Search and the product does appear there. It will be also displayed within the app if the user taps on it. All easily achievable so far.
Step 3. The user has the right to 'save' that product, so nobody else can get it before he does. So, once the product is saved, I would like to modify the details of the NSUserActivity so it can show on the description the product is saved. As far as I know I can't do that, as there is no API to do that.
Ideally, I would like to modify the description and the image, to let the user know that product belongs to him now, so I would make the NSUserActivity private and I would modify its properties, but I can't find a way.
On the other hand, I could use NSUserActivity to handle the public products and CoreSpotlight the saved ones, but in that scenario, the app would display twice the same product. One that is the saved and private, and the one that is public. Something I would like to avoid, as I want you to see only once the same product, in this case, the one you have saved and is yours.
Is there any way I can achieve that?
It's pretty easy to prevent item duplication. All you need to do is specifying the same value in relatedUniqueIdentifier (NSUserActivity) and uniqueIdentifier (CSSearchableItem).
This will also increase your ranking.
See the documentation for details.
I'm trying to move my app to use UIActivityViewController, rather than UIActionSheet, so that I get the fancy graphical sharing buttons rather than the textual buttons. (My app is targeted at iOS 6 only.)
After trying to work with it for a couple nights, it seems either I am totally misunderstanding how to use it, or the current implementation by Apple is terrible:
You can't specify a different message for different services. If I want something that will work across: Mail, Facebook, Messages AND Twitter, it's going to need to be 140 characters max, to work on Twitter. Is there a way to set custom content for each type of activity?
There appears to be no way to set a subject line or recipient for Mail messages. I've read the docs, they make it sound like this might be possible with an NSURL that uses the mailto: protocol, but in my tests, those URLs just get shoved into the message body. Is there actually a way to set the subject line and optionally, the recipients?
If I want to work around these shortcomings, and do my own custom activities by subclassing UIActivity, I have to use a custom image/icon. Therefore, I can't mimic the Mail activity with Apple's official icon, and e.g. implement my own custom activity backend that actually lets me set the subject line, recipients, custom body, etc. Am I wrong, is there a way to use Apple's service icons, but have a chance to customize the behavior? (The only callback I see is one that runs AFTER the activity has been completed, right?)
I hope I'm wrong!
Is there a way to set custom content for each type of activity?
Yes, I guess you should subclass UIActivityItemProvider and override method –activityViewController:itemForActivityType: with your logic (e.g. trim string to 140 chars for Twitter).
Then pass an instance of this class to -[UIActivityViewController initWithActivityItems:applicationActivities:].
Is there actually a way to set the subject line and optionally, the recipients?
You are right, the mailto scheme should be able to set these fields. If it is not working, I consider this as bug. (Didn't try this myself, but I will give it a check.)
Is there a way to use Apple's service icons, but have a chance to customize the behavior?
I think you can't do this. (Unless you want to hack those system activities.)
You are better off using a custom component that behaves like UIAcitvityController as it is quite limited, as you noted.
This is one example: https://github.com/hjnilsson/REActivityViewController , I just forked it from https://github.com/romaonthego/REActivityViewController to allow you to set the email subject field.
I am developing an iOS app in which I need a UIControl that allows the user to select between 2 options and 2 options only.
For example, assume I am displaying a form in my app in which the user fills up his personal information like Name, gender, hobbies etc. Here, gender is a possible field for which there are only 2 options (other options are possible, but let's say we don't want it in our app).
I thought it will be nice to use a customized version of the UISwitch for such a case.
But then, I am beginning to think that the UISwitch is applicable only in the context where something is enabled or disabled. Can it also be used in the context where user selects one of 2 choices? Does this go against Apple's design guidelines? If yes, then what other UIControl could I use for this? (I want to use something other than a plain dropdown)
UISegmentedControl is your choice.
You can feel free to use other controls (with customized look & feel) in your app, as long as it does not confuse users.
I'd suggest a UISegmentedControl, which has the behavior you require.
I'm working on a home automation project. Here's what I want to do:
The app starts and it'll have a button to load an XML file.
The XML will have information about the rooms in the house like "Living Room, Dining Room, Kitchen etc.". It'll also have information about the equipment, like "Home Theater, TV, Blu-Ray Player, etc. in this case with a relation with the room that they belong" and so on with IR, RS-232 cmds, etc.
I'll install this app in different houses, so I intend just to change the XML file as the house changes.
I intend to generate the UI from the information contained in the XML file. E.g. The house has only "Living Room and Dining Room". The tab bar will show only those two tabs.
So, my questions:
Will Apple reject my app?
Can my customers just download the app from the App Store, and change and load the XML file? I mean, there's a package in the .app file, is it possible to open it and change the .xml file inside it?
Is it possible to change the UI as the XML information changes?
EDIT: more questions:
#competent_tech is saying that dynamic generation of code isn't allowed, but I'll change the code within the .storyboard or .xib .nib files, isn't it?
About the Contacts: I think is a little bit different idea, because in the contacts app, e.g.: there are 10 fields to fill out, like first name, last name, e-mail, phone number, etc. As a user, if I don't fill out the e-mail field, it'll still be there anyway. My plan is kind of different:
The house has 2 equipments to control: - Tab bar with item 1 and item 2.
The house has 3 equipments to control: - Tab bar with item 1 and item 2 and item 3.
Do you still think this is possible?
Can you recommend a book about this? I couldn't find anything useful myself.
Unfortunately, only apple can answer the rejection question.
However, from what you have described, there shouldn't be an issue since this is configuration-based changes instead of code changes. Apple specifically prohibits download of code and dynamic generation of code.
You can liken it to Contacts: iOS doesn't come configured with contacts, they allow you add them and configure different things about them. This sounds very much like what you are doing.
You should be able to download an XML file from a website or web service and use that to configure the app. We use a web service to retrieve data into the local Sqlite database to configure nomenclature and UI component visibility based on the current user and it works quite nicely.
With generating code they mean executable code, not the generating of views or viewcontrollers. If that is forbidden too, you could distribute your app via addhoc, but you need one developer program per 99 clients.