HDLSceneSiri/HDLSceneSiri/HDLRunSceneIntent.h
@@ -38,7 +38,7 @@ @see HDLRunSceneIntentResponse */ - (void)handleRunScene:(HDLRunSceneIntent *)intent completion:(void (^)(HDLRunSceneIntentResponse *response))completion NS_SWIFT_NAME(handle(intent:completion:)); - (void)handleHDLRunScene:(HDLRunSceneIntent *)intent completion:(void (^)(HDLRunSceneIntentResponse *response))completion NS_SWIFT_NAME(handle(intent:completion:)); @optional @@ -51,7 +51,7 @@ @see HDLRunSceneIntentResponse */ - (void)confirmRunScene:(HDLRunSceneIntent *)intent completion:(void (^)(HDLRunSceneIntentResponse *response))completion NS_SWIFT_NAME(confirm(intent:completion:)); - (void)confirmHDLRunScene:(HDLRunSceneIntent *)intent completion:(void (^)(HDLRunSceneIntentResponse *response))completion NS_SWIFT_NAME(confirm(intent:completion:)); @end HDLSceneSiriDemo/HDLSceneSiri/HDLSceneHandler.h
New file @@ -0,0 +1,16 @@ // // HDLSceneHandler.h // HDLSceneSiri // // Created by 陈嘉乐 on 2021/11/25. // #import <Intents/Intents.h> #import "HDLRunSceneIntent.h" NS_ASSUME_NONNULL_BEGIN @interface HDLSceneHandler : INExtension<HDLRunSceneIntentHandling> @end NS_ASSUME_NONNULL_END HDLSceneSiriDemo/HDLSceneSiri/HDLSceneHandler.m
New file @@ -0,0 +1,36 @@ // // HDLSceneHandler.m // HDLSceneSiri // // Created by 陈嘉乐 on 2021/11/25. // #import "HDLSceneHandler.h" @implementation HDLSceneHandler // 该方法是在 siri 匹配到相应的 Intent 时候调用。 // 如果用失败的方法初始化HDLRunSceneIntentResponse,在匹siri后就会报错 // 不管用哪个成功的方式,只是初始化参数的值而已,都一样 // 此为第一道拦截,如果code设置为失败或者打开app,那就直接失败/跳走了,连展示界面的机会都没有 // 所以一半这里就直接返回成功,让siri继续往下走,打开界面 // 建议:只用reday和success 这两个code - (void)confirmRunScene:(HDLRunSceneIntent *)intent completion:(void (^)(HDLRunSceneIntentResponse *response))completion NS_SWIFT_NAME(confirm(intent:completion:)){ HDLRunSceneIntentResponse *rsp = [[HDLRunSceneIntentResponse alloc] initWithCode:HDLRunSceneIntentResponseCodeInProgress userActivity:nil]; rsp.successMessage =@"请等待..."; completion(rsp); } - (void)handleHDLRunScene:(nonnull HDLRunSceneIntent *)intent completion:(nonnull void (^)(HDLRunSceneIntentResponse * _Nonnull))completion { NSLog(@"HDL handleRunScene"); //执行成功 HDLRunSceneIntentResponse *rsp = [[HDLRunSceneIntentResponse alloc] initWithCode:HDLRunSceneIntentResponseCodeSuccess userActivity:nil]; rsp.sceneName = intent.sceneName; rsp.successMessage = @"执行成功"; completion(rsp); } @end HDLSceneSiriDemo/HDLSceneSiri/Info.plist
New file @@ -0,0 +1,22 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSExtension</key> <dict> <key>NSExtensionAttributes</key> <dict> <key>IntentsRestrictedWhileLocked</key> <array/> <key>IntentsSupported</key> <array> <string>HDLRunSceneIntent</string> </array> </dict> <key>NSExtensionPointIdentifier</key> <string>com.apple.intents-service</string> <key>NSExtensionPrincipalClass</key> <string>IntentHandler</string> </dict> </dict> </plist> HDLSceneSiriDemo/HDLSceneSiri/IntentHandler.h
New file @@ -0,0 +1,12 @@ // // IntentHandler.h // HDLSceneSiri // // Created by 陈嘉乐 on 2021/11/25. // #import <Intents/Intents.h> @interface IntentHandler : INExtension @end HDLSceneSiriDemo/HDLSceneSiri/IntentHandler.m
New file @@ -0,0 +1,127 @@ // // IntentHandler.m // HDLSceneSiri // // Created by 陈嘉乐 on 2021/11/25. // #import "IntentHandler.h" #import "HDLRunSceneIntent.h" #import "HDLSceneHandler.h" // As an example, this class is set up to handle Message intents. // You will want to replace this or add other intents as appropriate. // The intents you wish to handle must be declared in the extension's Info.plist. // You can test your example integration by saying things to Siri like: // "Send a message using <myApp>" // "<myApp> John saying hello" // "Search for messages in <myApp>" @interface IntentHandler () <INSendMessageIntentHandling, INSearchForMessagesIntentHandling, INSetMessageAttributeIntentHandling> @end @implementation IntentHandler - (id)handlerForIntent:(INIntent *)intent { // This is the default implementation. If you want different objects to handle different intents, // you can override this and return the handler you want for that particular intent. if (@available(iOS 12.0, *)) { if ([intent isKindOfClass:[HDLRunSceneIntent class]]) { return [[HDLSceneHandler alloc] init]; } } return self; } #pragma mark - INSendMessageIntentHandling // Implement resolution methods to provide additional information about your intent (optional). - (void)resolveRecipientsForSendMessage:(INSendMessageIntent *)intent with:(void (^)(NSArray<INSendMessageRecipientResolutionResult *> *resolutionResults))completion { NSArray<INPerson *> *recipients = intent.recipients; // If no recipients were provided we'll need to prompt for a value. if (recipients.count == 0) { completion(@[[INSendMessageRecipientResolutionResult needsValue]]); return; } NSMutableArray<INSendMessageRecipientResolutionResult *> *resolutionResults = [NSMutableArray array]; for (INPerson *recipient in recipients) { NSArray<INPerson *> *matchingContacts = @[recipient]; // Implement your contact matching logic here to create an array of matching contacts if (matchingContacts.count > 1) { // We need Siri's help to ask user to pick one from the matches. [resolutionResults addObject:[INSendMessageRecipientResolutionResult disambiguationWithPeopleToDisambiguate:matchingContacts]]; } else if (matchingContacts.count == 1) { // We have exactly one matching contact [resolutionResults addObject:[INSendMessageRecipientResolutionResult successWithResolvedPerson:recipient]]; } else { // We have no contacts matching the description provided [resolutionResults addObject:[INSendMessageRecipientResolutionResult unsupported]]; } } completion(resolutionResults); } - (void)resolveContentForSendMessage:(INSendMessageIntent *)intent withCompletion:(void (^)(INStringResolutionResult *resolutionResult))completion { NSString *text = intent.content; if (text && ![text isEqualToString:@""]) { completion([INStringResolutionResult successWithResolvedString:text]); } else { completion([INStringResolutionResult needsValue]); } } // Once resolution is completed, perform validation on the intent and provide confirmation (optional). - (void)confirmSendMessage:(INSendMessageIntent *)intent completion:(void (^)(INSendMessageIntentResponse *response))completion { // Verify user is authenticated and your app is ready to send a message. NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INSendMessageIntent class])]; INSendMessageIntentResponse *response = [[INSendMessageIntentResponse alloc] initWithCode:INSendMessageIntentResponseCodeReady userActivity:userActivity]; completion(response); } // Handle the completed intent (required). - (void)handleSendMessage:(INSendMessageIntent *)intent completion:(void (^)(INSendMessageIntentResponse *response))completion { // Implement your application logic to send a message here. NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INSendMessageIntent class])]; INSendMessageIntentResponse *response = [[INSendMessageIntentResponse alloc] initWithCode:INSendMessageIntentResponseCodeSuccess userActivity:userActivity]; completion(response); } // Implement handlers for each intent you wish to handle. As an example for messages, you may wish to also handle searchForMessages and setMessageAttributes. #pragma mark - INSearchForMessagesIntentHandling - (void)handleSearchForMessages:(INSearchForMessagesIntent *)intent completion:(void (^)(INSearchForMessagesIntentResponse *response))completion { // Implement your application logic to find a message that matches the information in the intent. NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INSearchForMessagesIntent class])]; INSearchForMessagesIntentResponse *response = [[INSearchForMessagesIntentResponse alloc] initWithCode:INSearchForMessagesIntentResponseCodeSuccess userActivity:userActivity]; // Initialize with found message's attributes response.messages = @[[[INMessage alloc] initWithIdentifier:@"identifier" content:@"I am so excited about SiriKit!" dateSent:[NSDate date] sender:[[INPerson alloc] initWithPersonHandle:[[INPersonHandle alloc] initWithValue:@"sarah@example.com" type:INPersonHandleTypeEmailAddress] nameComponents:nil displayName:@"Sarah" image:nil contactIdentifier:nil customIdentifier:nil] recipients:@[[[INPerson alloc] initWithPersonHandle:[[INPersonHandle alloc] initWithValue:@"+1-415-555-5555" type:INPersonHandleTypePhoneNumber] nameComponents:nil displayName:@"John" image:nil contactIdentifier:nil customIdentifier:nil]] ]]; completion(response); } #pragma mark - INSetMessageAttributeIntentHandling - (void)handleSetMessageAttribute:(INSetMessageAttributeIntent *)intent completion:(void (^)(INSetMessageAttributeIntentResponse *response))completion { // Implement your application logic to set the message attribute here. NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INSetMessageAttributeIntent class])]; INSetMessageAttributeIntentResponse *response = [[INSetMessageAttributeIntentResponse alloc] initWithCode:INSetMessageAttributeIntentResponseCodeSuccess userActivity:userActivity]; completion(response); } @end HDLSceneSiriDemo/HDLSceneSiriDemo.xcodeproj/project.pbxproj
@@ -16,13 +16,55 @@ B9595E602744D77D00948DB9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B9595E5F2744D77D00948DB9 /* main.m */; }; B9595E6B2744D80400948DB9 /* HDLSiriSceneListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B9595E682744D80400948DB9 /* HDLSiriSceneListCell.m */; }; B9595E6C2744D80400948DB9 /* HDLSiriSceneListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B9595E6A2744D80400948DB9 /* HDLSiriSceneListViewController.m */; }; B9595E7B2744D9D200948DB9 /* HDLRunSceneIntent.m in Sources */ = {isa = PBXBuildFile; fileRef = B9595E792744D9D200948DB9 /* HDLRunSceneIntent.m */; }; B9595E7E2744DA3B00948DB9 /* HDLSiriSceneModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B9595E7D2744DA3B00948DB9 /* HDLSiriSceneModel.m */; }; B9595E812744DA7000948DB9 /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9595E802744DA7000948DB9 /* Intents.framework */; }; B9595E842744DC9000948DB9 /* HDLSceneSiri.m in Sources */ = {isa = PBXBuildFile; fileRef = B9595E832744DC8F00948DB9 /* HDLSceneSiri.m */; }; B9595E9A2744E00100948DB9 /* TopBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = B9595E992744E00100948DB9 /* TopBarView.m */; }; B9595E9D2744E5E900948DB9 /* IntentsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9595E9C2744E5E900948DB9 /* IntentsUI.framework */; }; B9DD87EB274F7B8200E37C32 /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = B9DD87EA274F7B8200E37C32 /* Intents.intentdefinition */; }; B9DD87F1274F7CBC00E37C32 /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9595E802744DA7000948DB9 /* Intents.framework */; }; B9DD87F5274F7CBC00E37C32 /* IntentHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = B9DD87F4274F7CBC00E37C32 /* IntentHandler.m */; }; B9DD87FC274F7CBC00E37C32 /* IntentsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9595E9C2744E5E900948DB9 /* IntentsUI.framework */; }; B9DD8800274F7CBC00E37C32 /* IntentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B9DD87FF274F7CBC00E37C32 /* IntentViewController.m */; }; B9DD8803274F7CBC00E37C32 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9DD8801274F7CBC00E37C32 /* MainInterface.storyboard */; }; B9DD8808274F7CBC00E37C32 /* HDLSceneSiriUI.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = B9DD87FB274F7CBC00E37C32 /* HDLSceneSiriUI.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; B9DD880B274F7CBC00E37C32 /* HDLSceneSiri.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = B9DD87F0274F7CBC00E37C32 /* HDLSceneSiri.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; B9DD8812274F7CE000E37C32 /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = B9DD87EA274F7B8200E37C32 /* Intents.intentdefinition */; }; B9DD8813274F7CEC00E37C32 /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = B9DD87EA274F7B8200E37C32 /* Intents.intentdefinition */; }; B9DD8816274F7D0C00E37C32 /* HDLSceneHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = B9DD8815274F7D0C00E37C32 /* HDLSceneHandler.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ B9DD8805274F7CBC00E37C32 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = B9595E422744D77800948DB9 /* Project object */; proxyType = 1; remoteGlobalIDString = B9DD87FA274F7CBC00E37C32; remoteInfo = HDLSceneSiriUI; }; B9DD8809274F7CBC00E37C32 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = B9595E422744D77800948DB9 /* Project object */; proxyType = 1; remoteGlobalIDString = B9DD87EF274F7CBC00E37C32; remoteInfo = HDLSceneSiri; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ B9DD8807274F7CBC00E37C32 /* Embed App Extensions */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 13; files = ( B9DD8808274F7CBC00E37C32 /* HDLSceneSiriUI.appex in Embed App Extensions */, B9DD880B274F7CBC00E37C32 /* HDLSceneSiri.appex in Embed App Extensions */, ); name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ B9595E4A2744D77800948DB9 /* HDLSceneSiriDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HDLSceneSiriDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -41,8 +83,6 @@ B9595E682744D80400948DB9 /* HDLSiriSceneListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HDLSiriSceneListCell.m; sourceTree = "<group>"; }; B9595E692744D80400948DB9 /* HDLSiriSceneListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HDLSiriSceneListViewController.h; sourceTree = "<group>"; }; B9595E6A2744D80400948DB9 /* HDLSiriSceneListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HDLSiriSceneListViewController.m; sourceTree = "<group>"; }; B9595E792744D9D200948DB9 /* HDLRunSceneIntent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HDLRunSceneIntent.m; sourceTree = "<group>"; }; B9595E7A2744D9D200948DB9 /* HDLRunSceneIntent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HDLRunSceneIntent.h; sourceTree = "<group>"; }; B9595E7C2744DA3B00948DB9 /* HDLSiriSceneModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HDLSiriSceneModel.h; sourceTree = "<group>"; }; B9595E7D2744DA3B00948DB9 /* HDLSiriSceneModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HDLSiriSceneModel.m; sourceTree = "<group>"; }; B9595E802744DA7000948DB9 /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; }; @@ -52,6 +92,18 @@ B9595E992744E00100948DB9 /* TopBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopBarView.m; sourceTree = "<group>"; }; B9595E9B2744E49E00948DB9 /* HDLSceneSiriDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HDLSceneSiriDemo.entitlements; sourceTree = "<group>"; }; B9595E9C2744E5E900948DB9 /* IntentsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IntentsUI.framework; path = System/Library/Frameworks/IntentsUI.framework; sourceTree = SDKROOT; }; B9DD87EA274F7B8200E37C32 /* Intents.intentdefinition */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.intentdefinition; path = Intents.intentdefinition; sourceTree = "<group>"; }; B9DD87F0274F7CBC00E37C32 /* HDLSceneSiri.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = HDLSceneSiri.appex; sourceTree = BUILT_PRODUCTS_DIR; }; B9DD87F3274F7CBC00E37C32 /* IntentHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IntentHandler.h; sourceTree = "<group>"; }; B9DD87F4274F7CBC00E37C32 /* IntentHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IntentHandler.m; sourceTree = "<group>"; }; B9DD87F6274F7CBC00E37C32 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; B9DD87FB274F7CBC00E37C32 /* HDLSceneSiriUI.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = HDLSceneSiriUI.appex; sourceTree = BUILT_PRODUCTS_DIR; }; B9DD87FE274F7CBC00E37C32 /* IntentViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IntentViewController.h; sourceTree = "<group>"; }; B9DD87FF274F7CBC00E37C32 /* IntentViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IntentViewController.m; sourceTree = "<group>"; }; B9DD8802274F7CBC00E37C32 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; }; B9DD8804274F7CBC00E37C32 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; B9DD8814274F7D0B00E37C32 /* HDLSceneHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HDLSceneHandler.h; sourceTree = "<group>"; }; B9DD8815274F7D0C00E37C32 /* HDLSceneHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HDLSceneHandler.m; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -64,6 +116,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; B9DD87ED274F7CBC00E37C32 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( B9DD87F1274F7CBC00E37C32 /* Intents.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; B9DD87F8274F7CBC00E37C32 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( B9DD87FC274F7CBC00E37C32 /* IntentsUI.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -71,6 +139,8 @@ isa = PBXGroup; children = ( B9595E4C2744D77800948DB9 /* HDLSceneSiriDemo */, B9DD87F2274F7CBC00E37C32 /* HDLSceneSiri */, B9DD87FD274F7CBC00E37C32 /* HDLSceneSiriUI */, B9595E4B2744D77800948DB9 /* Products */, B9595E7F2744DA6F00948DB9 /* Frameworks */, ); @@ -80,6 +150,8 @@ isa = PBXGroup; children = ( B9595E4A2744D77800948DB9 /* HDLSceneSiriDemo.app */, B9DD87F0274F7CBC00E37C32 /* HDLSceneSiri.appex */, B9DD87FB274F7CBC00E37C32 /* HDLSceneSiriUI.appex */, ); name = Products; sourceTree = "<group>"; @@ -87,6 +159,7 @@ B9595E4C2744D77800948DB9 /* HDLSceneSiriDemo */ = { isa = PBXGroup; children = ( B9DD87EA274F7B8200E37C32 /* Intents.intentdefinition */, B9595E9B2744E49E00948DB9 /* HDLSceneSiriDemo.entitlements */, B9595E662744D79F00948DB9 /* HDLSceneSiri */, B9595E4D2744D77800948DB9 /* AppDelegate.h */, @@ -109,8 +182,6 @@ children = ( B9595E982744E00100948DB9 /* TopBarView.h */, B9595E992744E00100948DB9 /* TopBarView.m */, B9595E7A2744D9D200948DB9 /* HDLRunSceneIntent.h */, B9595E792744D9D200948DB9 /* HDLRunSceneIntent.m */, B9595E672744D80400948DB9 /* HDLSiriSceneListCell.h */, B9595E682744D80400948DB9 /* HDLSiriSceneListCell.m */, B9595E692744D80400948DB9 /* HDLSiriSceneListViewController.h */, @@ -132,6 +203,29 @@ name = Frameworks; sourceTree = "<group>"; }; B9DD87F2274F7CBC00E37C32 /* HDLSceneSiri */ = { isa = PBXGroup; children = ( B9DD87F3274F7CBC00E37C32 /* IntentHandler.h */, B9DD87F4274F7CBC00E37C32 /* IntentHandler.m */, B9DD87F6274F7CBC00E37C32 /* Info.plist */, B9DD8814274F7D0B00E37C32 /* HDLSceneHandler.h */, B9DD8815274F7D0C00E37C32 /* HDLSceneHandler.m */, ); path = HDLSceneSiri; sourceTree = "<group>"; }; B9DD87FD274F7CBC00E37C32 /* HDLSceneSiriUI */ = { isa = PBXGroup; children = ( B9DD87FE274F7CBC00E37C32 /* IntentViewController.h */, B9DD87FF274F7CBC00E37C32 /* IntentViewController.m */, B9DD8801274F7CBC00E37C32 /* MainInterface.storyboard */, B9DD8804274F7CBC00E37C32 /* Info.plist */, ); path = HDLSceneSiriUI; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -142,15 +236,52 @@ B9595E462744D77800948DB9 /* Sources */, B9595E472744D77800948DB9 /* Frameworks */, B9595E482744D77800948DB9 /* Resources */, B9DD8807274F7CBC00E37C32 /* Embed App Extensions */, ); buildRules = ( ); dependencies = ( B9DD8806274F7CBC00E37C32 /* PBXTargetDependency */, B9DD880A274F7CBC00E37C32 /* PBXTargetDependency */, ); name = HDLSceneSiriDemo; productName = HDLSceneSiriDemo; productReference = B9595E4A2744D77800948DB9 /* HDLSceneSiriDemo.app */; productType = "com.apple.product-type.application"; }; B9DD87EF274F7CBC00E37C32 /* HDLSceneSiri */ = { isa = PBXNativeTarget; buildConfigurationList = B9DD880F274F7CBC00E37C32 /* Build configuration list for PBXNativeTarget "HDLSceneSiri" */; buildPhases = ( B9DD87EC274F7CBC00E37C32 /* Sources */, B9DD87ED274F7CBC00E37C32 /* Frameworks */, B9DD87EE274F7CBC00E37C32 /* Resources */, ); buildRules = ( ); dependencies = ( ); name = HDLSceneSiri; productName = HDLSceneSiri; productReference = B9DD87F0274F7CBC00E37C32 /* HDLSceneSiri.appex */; productType = "com.apple.product-type.app-extension"; }; B9DD87FA274F7CBC00E37C32 /* HDLSceneSiriUI */ = { isa = PBXNativeTarget; buildConfigurationList = B9DD880C274F7CBC00E37C32 /* Build configuration list for PBXNativeTarget "HDLSceneSiriUI" */; buildPhases = ( B9DD87F7274F7CBC00E37C32 /* Sources */, B9DD87F8274F7CBC00E37C32 /* Frameworks */, B9DD87F9274F7CBC00E37C32 /* Resources */, ); buildRules = ( ); dependencies = ( ); name = HDLSceneSiriUI; productName = HDLSceneSiriUI; productReference = B9DD87FB274F7CBC00E37C32 /* HDLSceneSiriUI.appex */; productType = "com.apple.product-type.app-extension"; }; /* End PBXNativeTarget section */ @@ -162,6 +293,12 @@ LastUpgradeCheck = 1300; TargetAttributes = { B9595E492744D77800948DB9 = { CreatedOnToolsVersion = 13.0; }; B9DD87EF274F7CBC00E37C32 = { CreatedOnToolsVersion = 13.0; }; B9DD87FA274F7CBC00E37C32 = { CreatedOnToolsVersion = 13.0; }; }; @@ -180,6 +317,8 @@ projectRoot = ""; targets = ( B9595E492744D77800948DB9 /* HDLSceneSiriDemo */, B9DD87EF274F7CBC00E37C32 /* HDLSceneSiri */, B9DD87FA274F7CBC00E37C32 /* HDLSceneSiriUI */, ); }; /* End PBXProject section */ @@ -195,6 +334,21 @@ ); runOnlyForDeploymentPostprocessing = 0; }; B9DD87EE274F7CBC00E37C32 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; B9DD87F9274F7CBC00E37C32 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( B9DD8803274F7CBC00E37C32 /* MainInterface.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -207,15 +361,47 @@ B9595E7E2744DA3B00948DB9 /* HDLSiriSceneModel.m in Sources */, B9595E4F2744D77800948DB9 /* AppDelegate.m in Sources */, B9595E602744D77D00948DB9 /* main.m in Sources */, B9595E7B2744D9D200948DB9 /* HDLRunSceneIntent.m in Sources */, B9595E522744D77800948DB9 /* SceneDelegate.m in Sources */, B9595E6C2744D80400948DB9 /* HDLSiriSceneListViewController.m in Sources */, B9595E9A2744E00100948DB9 /* TopBarView.m in Sources */, B9DD87EB274F7B8200E37C32 /* Intents.intentdefinition in Sources */, B9595E6B2744D80400948DB9 /* HDLSiriSceneListCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; B9DD87EC274F7CBC00E37C32 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( B9DD8816274F7D0C00E37C32 /* HDLSceneHandler.m in Sources */, B9DD8812274F7CE000E37C32 /* Intents.intentdefinition in Sources */, B9DD87F5274F7CBC00E37C32 /* IntentHandler.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; B9DD87F7274F7CBC00E37C32 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( B9DD8813274F7CEC00E37C32 /* Intents.intentdefinition in Sources */, B9DD8800274F7CBC00E37C32 /* IntentViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ B9DD8806274F7CBC00E37C32 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = B9DD87FA274F7CBC00E37C32 /* HDLSceneSiriUI */; targetProxy = B9DD8805274F7CBC00E37C32 /* PBXContainerItemProxy */; }; B9DD880A274F7CBC00E37C32 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = B9DD87EF274F7CBC00E37C32 /* HDLSceneSiri */; targetProxy = B9DD8809274F7CBC00E37C32 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ B9595E562744D77800948DB9 /* Main.storyboard */ = { @@ -232,6 +418,14 @@ B9595E5C2744D77D00948DB9 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = "<group>"; }; B9DD8801274F7CBC00E37C32 /* MainInterface.storyboard */ = { isa = PBXVariantGroup; children = ( B9DD8802274F7CBC00E37C32 /* Base */, ); name = MainInterface.storyboard; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ @@ -405,6 +599,106 @@ }; name = Release; }; B9DD880D274F7CBC00E37C32 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = BVTA78PRYA; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = HDLSceneSiriUI/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = HDLSceneSiriUI; INFOPLIST_KEY_NSHumanReadableCopyright = ""; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.hdl.HDLSceneSiriDemo.HDLSceneSiriUI; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; B9DD880E274F7CBC00E37C32 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = BVTA78PRYA; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = HDLSceneSiriUI/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = HDLSceneSiriUI; INFOPLIST_KEY_NSHumanReadableCopyright = ""; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.hdl.HDLSceneSiriDemo.HDLSceneSiriUI; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; B9DD8810274F7CBC00E37C32 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = BVTA78PRYA; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = HDLSceneSiri/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = HDLSceneSiri; INFOPLIST_KEY_NSHumanReadableCopyright = ""; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.hdl.HDLSceneSiriDemo.HDLSceneSiri; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; B9DD8811274F7CBC00E37C32 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = BVTA78PRYA; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = HDLSceneSiri/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = HDLSceneSiri; INFOPLIST_KEY_NSHumanReadableCopyright = ""; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.hdl.HDLSceneSiriDemo.HDLSceneSiri; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -426,6 +720,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; B9DD880C274F7CBC00E37C32 /* Build configuration list for PBXNativeTarget "HDLSceneSiriUI" */ = { isa = XCConfigurationList; buildConfigurations = ( B9DD880D274F7CBC00E37C32 /* Debug */, B9DD880E274F7CBC00E37C32 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; B9DD880F274F7CBC00E37C32 /* Build configuration list for PBXNativeTarget "HDLSceneSiri" */ = { isa = XCConfigurationList; buildConfigurations = ( B9DD8810274F7CBC00E37C32 /* Debug */, B9DD8811274F7CBC00E37C32 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = B9595E422744D77800948DB9 /* Project object */; HDLSceneSiriDemo/HDLSceneSiriDemo/Intents.intentdefinition
New file @@ -0,0 +1,181 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>INEnums</key> <array/> <key>INIntentDefinitionModelVersion</key> <string>1.2</string> <key>INIntentDefinitionNamespace</key> <string>8yVV3C</string> <key>INIntentDefinitionSystemVersion</key> <string>20G165</string> <key>INIntentDefinitionToolsBuildVersion</key> <string>13A233</string> <key>INIntentDefinitionToolsVersion</key> <string>13.0</string> <key>INIntents</key> <array> <dict> <key>INIntentCategory</key> <string>generic</string> <key>INIntentDescription</key> <string>Run Scene</string> <key>INIntentDescriptionID</key> <string>Pe02nj</string> <key>INIntentLastParameterTag</key> <integer>2</integer> <key>INIntentName</key> <string>HDLRunScene</string> <key>INIntentParameterCombinations</key> <dict> <key>sceneName,sceneId</key> <dict> <key>INIntentParameterCombinationIsPrimary</key> <true/> <key>INIntentParameterCombinationSupportsBackgroundExecution</key> <true/> <key>INIntentParameterCombinationTitle</key> <string>执行场景“${sceneName}”</string> <key>INIntentParameterCombinationTitleID</key> <string>oCGdw4</string> </dict> </dict> <key>INIntentParameters</key> <array> <dict> <key>INIntentParameterDisplayName</key> <string>Scene Name</string> <key>INIntentParameterDisplayNameID</key> <string>wC0SgK</string> <key>INIntentParameterDisplayPriority</key> <integer>1</integer> <key>INIntentParameterMetadata</key> <dict> <key>INIntentParameterMetadataCapitalization</key> <string>Sentences</string> <key>INIntentParameterMetadataDefaultValueID</key> <string>xz2KkJ</string> </dict> <key>INIntentParameterName</key> <string>sceneName</string> <key>INIntentParameterTag</key> <integer>1</integer> <key>INIntentParameterType</key> <string>String</string> </dict> <dict> <key>INIntentParameterDisplayName</key> <string>Scene Id</string> <key>INIntentParameterDisplayNameID</key> <string>MtgGtd</string> <key>INIntentParameterDisplayPriority</key> <integer>2</integer> <key>INIntentParameterMetadata</key> <dict> <key>INIntentParameterMetadataCapitalization</key> <string>Sentences</string> <key>INIntentParameterMetadataDefaultValueID</key> <string>hQHCm1</string> </dict> <key>INIntentParameterName</key> <string>sceneId</string> <key>INIntentParameterTag</key> <integer>2</integer> <key>INIntentParameterType</key> <string>String</string> </dict> </array> <key>INIntentResponse</key> <dict> <key>INIntentResponseCodes</key> <array> <dict> <key>INIntentResponseCodeFormatString</key> <string>${sceneName}</string> <key>INIntentResponseCodeFormatStringID</key> <string>Pq8YBC</string> <key>INIntentResponseCodeName</key> <string>success</string> <key>INIntentResponseCodeSuccess</key> <true/> </dict> <dict> <key>INIntentResponseCodeFormatString</key> <string>${errorMessage}</string> <key>INIntentResponseCodeFormatStringID</key> <string>CX5DVI</string> <key>INIntentResponseCodeName</key> <string>failure</string> </dict> <dict> <key>INIntentResponseCodeName</key> <string>error</string> <key>INIntentResponseCodeSuccess</key> <true/> </dict> </array> <key>INIntentResponseLastParameterTag</key> <integer>3</integer> <key>INIntentResponseParameters</key> <array> <dict> <key>INIntentResponseParameterDisplayName</key> <string>Error Message</string> <key>INIntentResponseParameterDisplayNameID</key> <string>HxQb2M</string> <key>INIntentResponseParameterDisplayPriority</key> <integer>1</integer> <key>INIntentResponseParameterName</key> <string>errorMessage</string> <key>INIntentResponseParameterTag</key> <integer>1</integer> <key>INIntentResponseParameterType</key> <string>String</string> </dict> <dict> <key>INIntentResponseParameterDisplayName</key> <string>Success Message</string> <key>INIntentResponseParameterDisplayNameID</key> <string>BaAbSP</string> <key>INIntentResponseParameterDisplayPriority</key> <integer>2</integer> <key>INIntentResponseParameterName</key> <string>successMessage</string> <key>INIntentResponseParameterTag</key> <integer>2</integer> <key>INIntentResponseParameterType</key> <string>String</string> </dict> <dict> <key>INIntentResponseParameterDisplayName</key> <string>Scene Name</string> <key>INIntentResponseParameterDisplayNameID</key> <string>pqg7cb</string> <key>INIntentResponseParameterDisplayPriority</key> <integer>3</integer> <key>INIntentResponseParameterName</key> <string>sceneName</string> <key>INIntentResponseParameterTag</key> <integer>3</integer> <key>INIntentResponseParameterType</key> <string>String</string> </dict> </array> </dict> <key>INIntentRestrictions</key> <integer>1</integer> <key>INIntentTitle</key> <string>Run Scene</string> <key>INIntentTitleID</key> <string>j3jRXP</string> <key>INIntentType</key> <string>Custom</string> <key>INIntentVerb</key> <string>Do</string> </dict> </array> <key>INTypes</key> <array/> </dict> </plist> HDLSceneSiriDemo/HDLSceneSiriUI/Base.lproj/MainInterface.storyboard
New file @@ -0,0 +1,52 @@ <?xml version="1.0" encoding="UTF-8"?> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ObA-dk-sSI"> <device id="retina6_1" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <scenes> <!--Intent View Controller--> <scene sceneID="7MM-of-jgj"> <objects> <viewController id="ObA-dk-sSI" customClass="IntentViewController" sceneMemberID="viewController"> <view key="view" contentMode="scaleToFill" id="zMn-AG-sqS"> <rect key="frame" x="0.0" y="0.0" width="320" height="150"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qr8-Ok-8TQ"> <rect key="frame" x="0.0" y="0.0" width="320" height="150"/> <fontDescription key="fontDescription" type="system" pointSize="17"/> <nil key="textColor"/> <nil key="highlightedColor"/> </label> </subviews> <viewLayoutGuide key="safeArea" id="4PN-XC-lEE"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstItem="Qr8-Ok-8TQ" firstAttribute="top" secondItem="zMn-AG-sqS" secondAttribute="top" id="115-YJ-kb8"/> <constraint firstItem="Qr8-Ok-8TQ" firstAttribute="leading" secondItem="4PN-XC-lEE" secondAttribute="leading" id="ZOP-bk-OA8"/> <constraint firstItem="4PN-XC-lEE" firstAttribute="bottom" secondItem="Qr8-Ok-8TQ" secondAttribute="bottom" id="ati-tP-QP0"/> <constraint firstItem="4PN-XC-lEE" firstAttribute="trailing" secondItem="Qr8-Ok-8TQ" secondAttribute="trailing" id="cHK-cQ-vse"/> </constraints> </view> <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <size key="freeformSize" width="320" height="150"/> <connections> <outlet property="messageLabel" destination="Qr8-Ok-8TQ" id="7dL-Bn-nSk"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="X47-rx-isc" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="35" y="50"/> </scene> </scenes> <resources> <systemColor name="systemBackgroundColor"> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </systemColor> </resources> </document> HDLSceneSiriDemo/HDLSceneSiriUI/Info.plist
New file @@ -0,0 +1,20 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSExtension</key> <dict> <key>NSExtensionAttributes</key> <dict> <key>IntentsSupported</key> <array> <string>HDLRunSceneIntent</string> </array> </dict> <key>NSExtensionMainStoryboard</key> <string>MainInterface</string> <key>NSExtensionPointIdentifier</key> <string>com.apple.intents-ui-service</string> </dict> </dict> </plist> HDLSceneSiriDemo/HDLSceneSiriUI/IntentViewController.h
New file @@ -0,0 +1,13 @@ // // IntentViewController.h // HDLSceneSiriUI // // Created by 陈嘉乐 on 2021/11/25. // #import <IntentsUI/IntentsUI.h> @interface IntentViewController : UIViewController <INUIHostedViewControlling> @property (weak, nonatomic) IBOutlet UILabel *messageLabel; @end HDLSceneSiriDemo/HDLSceneSiriUI/IntentViewController.m
New file @@ -0,0 +1,59 @@ // // IntentViewController.m // HDLSceneSiriUI // // Created by 陈嘉乐 on 2021/11/25. // #import "IntentViewController.h" #import "HDLRunSceneIntent.h" // As an example, this extension's Info.plist has been configured to handle interactions for INSendMessageIntent. // You will want to replace this or add other intents as appropriate. // The intents whose interactions you wish to handle must be declared in the extension's Info.plist. // You can test this example integration by saying things to Siri like: // "Send a message using <myApp>" @interface IntentViewController () @end @implementation IntentViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } #pragma mark - INUIHostedViewControlling // Prepare your view controller for the interaction to handle. - (void)configureViewForParameters:(NSSet <INParameter *> *)parameters ofInteraction:(INInteraction *)interaction interactiveBehavior:(INUIInteractiveBehavior)interactiveBehavior context:(INUIHostedViewContext)context completion:(void (^)(BOOL success, NSSet <INParameter *> *configuredParameters, CGSize desiredSize))completion { // Do configuration here, including preparing views and calculating a desired size for presentation. if (@available(iOS 12.0, *)) { HDLRunSceneIntentResponse *rsp = (HDLRunSceneIntentResponse *) interaction.intentResponse; // HDLRunSceneIntent *intent = (HDLRunSceneIntent *)interaction.intent; NSLog(@"HDL code:%ld s:%@ e:%@",(long)rsp.code,rsp.successMessage,rsp.errorMessage); // self.messageLabel.hidden = NO; if (rsp.code == HDLRunSceneIntentResponseCodeSuccess) { self.messageLabel.text = [NSString stringWithFormat: @"%@",rsp.successMessage]; }else if (rsp.code == HDLRunSceneIntentResponseCodeFailure || rsp.code == HDLRunSceneIntentResponseCodeError) { self.messageLabel.text = [NSString stringWithFormat: @"%@",rsp.errorMessage]; }else{ self.messageLabel.text = [NSString stringWithFormat: @"%@",rsp.successMessage]; } } else { // Fallback on earlier versions } CGSize size = CGSizeMake([self desiredSize].width, 80); if (completion) { completion(YES, parameters, size); } } - (CGSize)desiredSize { return [self extensionContext].hostedViewMaximumAllowedSize; } @end Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/ApiDefinition.cs
@@ -6,6 +6,44 @@ namespace HDLSceneSiri { // @interface HDLSiriSceneListViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> [BaseType(typeof(UIViewController))] interface HDLSiriSceneListViewController : IUITableViewDataSource, IUITableViewDelegate { // @property (assign, nonatomic) UITableViewStyle tableViewStyle; [Export("tableViewStyle", ArgumentSemantic.Assign)] UITableViewStyle TableViewStyle { get; set; } // @property (nonatomic, strong) UITableView * _Nonnull tableView; [Export("tableView", ArgumentSemantic.Strong)] UITableView TableView { get; set; } [Wrap("WeakDataSource")] NSMutableArray DataSource { get; set; } // @property (nonatomic, strong) NSMutableArray * _Nonnull dataSource; [NullAllowed, Export("dataSource", ArgumentSemantic.Strong)] NSObject WeakDataSource { get; set; } // @property (nonatomic, strong) NSString * _Nonnull titleName; [Export("titleName", ArgumentSemantic.Strong)] string TitleName { get; set; } } // @interface HDLSiriSceneModel : NSObject [BaseType(typeof(NSObject))] interface HDLSiriSceneModel { // @property (copy, nonatomic) NSString * _Nonnull userSceneId; [Export("userSceneId")] string UserSceneId { get; set; } // @property (copy, nonatomic) NSString * _Nonnull name; [Export("name")] string Name { get; set; } } // @interface HDLRunSceneIntent : INIntent [Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)] [BaseType(typeof(INIntent))] @@ -35,14 +73,14 @@ [BaseType(typeof(NSObject))] interface HDLRunSceneIntentHandling { // @required -(void)handleRunScene:(HDLRunSceneIntent * _Nonnull)intent completion:(void (^ _Nonnull)(HDLRunSceneIntentResponse * _Nonnull))completion __attribute__((swift_name("handle(intent:completion:)"))); // @required -(void)handleHDLRunScene:(HDLRunSceneIntent * _Nonnull)intent completion:(void (^ _Nonnull)(HDLRunSceneIntentResponse * _Nonnull))completion __attribute__((swift_name("handle(intent:completion:)"))); [Abstract] [Export("handleRunScene:completion:")] void HandleRunScene(HDLRunSceneIntent intent, Action<HDLRunSceneIntentResponse> completion); [Export("handleHDLRunScene:completion:")] void HandleHDLRunScene(HDLRunSceneIntent intent, Action<HDLRunSceneIntentResponse> completion); // @optional -(void)confirmRunScene:(HDLRunSceneIntent * _Nonnull)intent completion:(void (^ _Nonnull)(HDLRunSceneIntentResponse * _Nonnull))completion __attribute__((swift_name("confirm(intent:completion:)"))); [Export("confirmRunScene:completion:")] void ConfirmRunScene(HDLRunSceneIntent intent, Action<HDLRunSceneIntentResponse> completion); // @optional -(void)confirmHDLRunScene:(HDLRunSceneIntent * _Nonnull)intent completion:(void (^ _Nonnull)(HDLRunSceneIntentResponse * _Nonnull))completion __attribute__((swift_name("confirm(intent:completion:)"))); [Export("confirmHDLRunScene:completion:")] void ConfirmHDLRunScene(HDLRunSceneIntent intent, Action<HDLRunSceneIntentResponse> completion); } // @interface HDLRunSceneIntentResponse : INIntentResponse @@ -81,42 +119,5 @@ // @property (readonly, nonatomic) HDLRunSceneIntentResponseCode code; [Export("code")] HDLRunSceneIntentResponseCode Code { get; } } // @interface HDLSiriSceneListViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> [BaseType(typeof(UIViewController))] interface HDLSiriSceneListViewController : IUITableViewDataSource, IUITableViewDelegate { // @property (assign, nonatomic) UITableViewStyle tableViewStyle; [Export("tableViewStyle", ArgumentSemantic.Assign)] UITableViewStyle TableViewStyle { get; set; } // @property (nonatomic, strong) UITableView * _Nonnull tableView; [Export("tableView", ArgumentSemantic.Strong)] UITableView TableView { get; set; } [Wrap("WeakDataSource")] NSMutableArray DataSource { get; set; } // @property (nonatomic, strong) NSMutableArray * _Nonnull dataSource; [NullAllowed, Export("dataSource", ArgumentSemantic.Strong)] NSObject WeakDataSource { get; set; } // @property (nonatomic, strong) NSString * _Nonnull titleName; [Export("titleName", ArgumentSemantic.Strong)] string TitleName { get; set; } } // @interface HDLSiriSceneModel : NSObject [BaseType(typeof(NSObject))] interface HDLSiriSceneModel { // @property (copy, nonatomic) NSString * _Nonnull userSceneId; [Export("userSceneId")] string UserSceneId { get; set; } // @property (copy, nonatomic) NSString * _Nonnull name; [Export("name")] string Name { get; set; } } } Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Library/libHDLSceneSiri.aBinary files differ
Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Properties/AssemblyInfo.cs
@@ -25,7 +25,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("1.0.1")] [assembly: AssemblyVersion("1.0.2")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing.