Show QR code with Siri, IOS11, ingetvisualcodeintent

Source: Internet
Author: User

Soon, IOS11 will come out.

In this update, Siri will support the display of QR codes. Payment, request payment, various requirements of the two-dimensional code.

It sounds like a good idea, and Apple's intention to make it easy to pay has been communicated.

Just really will be more convenient than to open the app to show QR code.

Or, imagine everyone using Siri to display the payment Code screen.

The convenience store ranks, "My payment Code", "Quick Show my QR code", "QR Code".

Siri says, "21 yards"???

(Maybe I don't use Siri, the scene is reproduced all by imagination)

Well, no matter what. You can start by doing a demo experience.

I haven't done anything to support Siri before, and it's easy to try something unexpected.

0. Install Xcode 9 Beta latest version and iOS11 1. Prepare app ID to support Sirikit

Fill in the bundle ID and tick support Sirikit.

2. Prepare the corresponding provisioning profile 3. Create or open an existing project. Set bundle identifier and provisioning profile are prepared for the previous 4. Select target for Project. Enable Siri in capability

5. Add intents App to Project Extension

Because the app's QR code is to be displayed, the Include UI extension should be ticked.

Then you will find that you have added two target.

6. Set the nsextension of the info.plist for these two target

Siriqrcodeintents's:

Siriqrcodeintentsui's:

*intentsrestrictedwhilelocked is set to unlock the lock screen in order to continue. In fact, there is no add, payment related intent default needs to be unlocked.

7. Create Handler

Under Siriqrcodeintents Project, create a new class that implements the Ingetvisualcodeintenthandling protocol.

Import Foundationimport Intentsclass Getvisualcodeintenthandler:nsobject, ingetvisualcodeintenthandling {    func Handle (intent:ingetvisualcodeintent, Completion: @escaping (Ingetvisualcodeintentresponse), Void) {        Completion (Ingetvisualcodeintentresponse (code:INGetVisualCodeIntentResponseCode.success, Useractivity:nil))    }}

  

Used in the handler method of the default Intenthandler class.

Override Func handler (for intent:inintent), any {        //This is the default implementation.  If you want different objects to handle different intents,        //can override this and return the handler you want fo R that particular intent.        If intent is ingetvisualcodeintent {            return Getvisualcodeintenthandler ()        }        return to self}

  

8. Run and see.

So far, your app has successfully entered the list of candidate apps for commands like "Payment Code"!

Select the target that you want to debug, and then run! (Only real machine)

Choose Siri when you select the app.

Then give Siri the orders!! "Show me My payment code"?

Then if your app name shows up, OK.

9. Nothing at all. How exactly does the QR code appear??

This will require the Siriqrcodeintentsui that you added earlier.

My words, I put a QR code into the Maininterface.storyboard.

Run for a while and find it so that it shows up and satisfies.??

10. Oh no, before that, adjust the size.

In the Siriqrcodeintentsui of the Intentviewcontroller in a random set up a bit high 200.

    Prepare your view controller for the interaction to handle.    Func Configureview (for Parameters:set<inparameter>, of Interaction:ininteraction, Interactivebehavior: Inuiinteractivebehavior, Context:inuihostedviewcontext, Completion: @escaping (Bool, Set<inparameter>, CGSize) Void) {        //do-configuration here, including preparing views and calculating a desired size for presentation.
   
    completion (True, parameters, Self.desiredsize)    }        var desiredsize:cgsize {        return cgsize (width: extensioncontext!. Hostedviewminimumallowedsize.width, height:200)    }
   

  

Demo results and Impressions

Do not feel fast and convenient. Also often identify the wrong.??

Also can not rule out the possibility of Japanese inarticulate.

The so-called display of the two-dimensional code support, just support the command section, to display the QR code or need to provide the app ~ ~

Reference:

Https://developer.apple.com/documentation/sirikit/creating_an_intents_app_extension

Https://developer.apple.com/documentation/sirikit/ingetvisualcodeintent

Https://developer.apple.com/documentation/sirikit/ingetvisualcodeintenthandling

Show QR code with Siri, IOS11, ingetvisualcodeintent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.