Giter VIP home page Giter VIP logo

assistantplus's Introduction

AssistantPlus Developer Guide

Lifecycle of Plugin:

  1. Principal class of bundle is loaded and initWithPluginManager: is called. Here is where you should register your commmands and snippets.

  2. User says something to Siri and your commands' handleSpeech:withTokens:withSession: method is called. If you want your plugin to handle the query then you should return YES, otherwise return NO. You should try to return an answer as soon as possible and then do any heavy work asynchronously.

  3. If you've returned YES, then you can start sending views to the current session, either your own custom snippets or the default text snippets.

  4. Once you're done you should call sendRequestCompleted on the current APSiriSession to end the request. If you don't do this the session could potentially timeout and Siri will give the user an error message.

Sending Views:

Views can be sent to the current Siri session in two ways:

You can queue up the views in an NSArray and send them all at once using sendAddViews:

      NSMutableDictionary *textSnippet = [session createTextSnippet:@"Here's what I found..."];
      NSMutableDictionary *customSnippet = [session createSnippet:@"SpotifySearchResultsViewController" properties:@{@"tracks" : [trackResults subarrayWithRange:NSMakeRange(0, MIN(trackResults.count, 5))],
                                                                                        @"albums" : [albumResults subarrayWithRange:NSMakeRange(0, MIN(albumResults.count, 5))],
                                                                                        @"artists" : [artistResults subarrayWithRange:NSMakeRange(0, MIN(artistResults.count, 5))]}];
      [session sendAddViews:@[textSnippet, customSnippet]];
      

Or, you can send the views one by one using sendTextSnippet: and sendCustomSnippet:

      [session sendTextSnippet:@"Here's what I found..." temporary:NO scrollToTop:NO dialogPhase:@"Summary"];
      [session sendCustomSnippet:@"SpotifySearchResultsViewController" withProperties:@{@"tracks" : [trackResults subarrayWithRange:NSMakeRange(0, MIN(trackResults.count, 5))],
                                                                                      @"albums" : [albumResults subarrayWithRange:NSMakeRange(0, MIN(albumResults.count, 5))],
                                                                                      @"artists" : [artistResults subarrayWithRange:NSMakeRange(0, MIN(artistResults.count, 5))]}];
```

### Custom Snippets:
Your custom snippet class must be a subclass of UIViewController and conform to the APPluginSnippet protocol. If you choose to not implement initWithProperties: then you will not be able to receive any properties you send your snippet using sendCustomSnippet:withProperties:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.