AssistantPlus-Developer-Guide/AssistantPlusHeaders.h
2015-04-04 15:14:50 -07:00

100 lines
4.4 KiB
Objective-C

//
// AssistantPlusHeaders.h
// For use with Assistant+ v1.0
//
// Created by Zaid Elkurdi on 2/28/15.
//
//
#ifndef _AssistantPlusHeaders_h
#define _AssistantPlusHeaders_h
// Represents the current Siri session
@protocol APSiriSession <NSObject>
/* Send a simple text snippet that Siri will read.
temporary: If true then the snippet will be replaced by the next view sent to the session.
For this to function properly the dialogPhase should be "Reflection"
scrollToTop: If true the Siri UI will be scrolled down so that the new view is at the top.
dialogPhase: Possible values are Completion, Reflection, Summary, Error, Clarification, and Acknowledgement */
- (void)sendTextSnippet:(NSString*)text temporary:(BOOL)temporary scrollToTop:(BOOL)toTop dialogPhase:(NSString*)phase;
/* Create an editable dictionary representing a text snippet. In order to send this
to the user you must add it to an NSArray and use sendAddviews: */
-(NSMutableDictionary*)createTextSnippet:(NSString*)text;
/* Send several views to the user at once */
- (void)sendAddViews:(NSArray*)views;
/* Send several views to the user with control over the parameters */
- (void)sendAddViews:(NSArray*)views dialogPhase:(NSString*)dialogPhase scrollToTop:(BOOL)toTop temporary:(BOOL)temporary;
/* Create and immediately send a custom snippet with the specified properties. The snippet must
have been registered with the plugin manager */
- (void)sendCustomSnippet:(NSString*)snippetClass withProperties:(NSDictionary*)props;
/* Create an editable dictionary representing a custom snippet. In order to send this
to the user you must add it to an NSArray and use sendAddViews: */
-(NSMutableDictionary*)createSnippet:(NSString*)snippetClass properties:(NSDictionary*)props;
/* Tell the session that you're done with this request and that it can end. You must do
this or Siri will timeout and display an error message.*/
- (void)sendRequestCompleted;
/* Retrieve the user's current location and then execute the code in the completion block
with the location info. The location info will be structured as follows:
NSDictionary *dict = @{@"latitude" : NSNumber,
@"longitude" : NSNumber,
@"horizontalAccuracy" : NSNumber,
@"verticalAccuracy" : NSNumber,
@"speed" : NSNumber,
@"course" : NSNumber,
@"timestamp" : NSDate} */
- (void)getCurrentLocationWithCompletion:(void (^)(NSDictionary *locationInfo))completion;
@end
/* None of your classes should need to conform to this protocol, but you will use it to register
your command and snippet classes when your principal class's (the one that conforms to APPlugin)
initWithSystem: method is called */
@protocol APPluginManager <NSObject>
@required
-(BOOL)registerCommand:(Class)commandClass;
-(BOOL)registerSnippet:(Class)snippetClass;
@end
/* Your custom snippet class (which should always be a subclass of UIViewController)
will need to conform to this protocol */
@protocol APPluginSnippet <NSObject>
@optional
/* If you use APSiriSession's sendCustomSnippet:withProperties: and want to be able
to access the properties in your snippet then you must implement this method. If you
don't implement this method then the snippet will be created with [yourSnippet init] */
-(id)initWithProperties:(NSDictionary*)props;
@end
/* This is where you will handle the user's query and determine if your plugin
should handle it. This "command" class should essentially be the brain of your plugin
and determine which snippet/s to show or action/s to take */
@protocol APPluginCommand <NSObject>
@required
/* You should try to make this method run as quickly as possible, as this method will be called on
all installed plugins or until one returns YES. If you've determined that your plugin should handle
the user's query then do any time-intensive tasks (such as network calls) on another thread */
-(BOOL)handleSpeech:(NSString*)text withTokens:(NSSet*)tokens withSession:(id<APSiriSession>)session;
@end
/* Your principal/"main" class should conform to this protocol. */
@protocol APPlugin <NSObject>
@required
/* When your plugin is initialized the plugin manager will call this method. This is
when you should register you command/s and snippet/s using the system's registerCommand: and
registerSnippet: methods, repsectively. */
-(id)initWithPluginManager:(id<APPluginManager>)manager;
@end
#endif