From f26dfd48aa7bf4c194863cc3b3f47d38bc8a2d57 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 26 十一月 2021 09:20:45 +0800
Subject: [PATCH] 2021-11-26 1.更新
---
Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/ApiDefinition.cs | 12 +-
HDLSceneSiriDemo/HDLSceneSiri/IntentHandler.m | 178 ++++++++++++++++++++++----------------------
Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri.csproj | 2
Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Structs.cs | 2
4 files changed, 98 insertions(+), 96 deletions(-)
diff --git a/HDLSceneSiriDemo/HDLSceneSiri/IntentHandler.m b/HDLSceneSiriDemo/HDLSceneSiri/IntentHandler.m
index 252fa34..96a5c81 100644
--- a/HDLSceneSiriDemo/HDLSceneSiri/IntentHandler.m
+++ b/HDLSceneSiriDemo/HDLSceneSiri/IntentHandler.m
@@ -18,7 +18,7 @@
// "<myApp> John saying hello"
// "Search for messages in <myApp>"
-@interface IntentHandler () <INSendMessageIntentHandling, INSearchForMessagesIntentHandling, INSetMessageAttributeIntentHandling>
+@interface IntentHandler ()
@end
@@ -35,93 +35,93 @@
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);
-}
+//
+//#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
diff --git a/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/ApiDefinition.cs b/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/ApiDefinition.cs
index 2905663..38b1264 100644
--- a/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/ApiDefinition.cs
+++ b/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/ApiDefinition.cs
@@ -45,7 +45,7 @@
}
// @interface HDLRunSceneIntent : INIntent
- [Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)]
+ //[Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)]
[BaseType(typeof(INIntent))]
interface HDLRunSceneIntent
{
@@ -68,9 +68,11 @@
protocol, then [Model] is redundant and will generate code that will never
be used.
*/
- [Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)]
- [Protocol]
- [BaseType(typeof(NSObject))]
+
+ //[Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)]
+ //[Protocol]
+ [Protocol, Model]
+ [BaseType(typeof(NSObject))]
interface HDLRunSceneIntentHandling
{
// @required -(void)handleHDLRunScene:(HDLRunSceneIntent * _Nonnull)intent completion:(void (^ _Nonnull)(HDLRunSceneIntentResponse * _Nonnull))completion __attribute__((swift_name("handle(intent:completion:)")));
@@ -84,7 +86,7 @@
}
// @interface HDLRunSceneIntentResponse : INIntentResponse
- [Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)]
+ //[Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)]
[BaseType(typeof(INIntentResponse))]
[DisableDefaultCtor]
interface HDLRunSceneIntentResponse
diff --git a/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri.csproj b/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri.csproj
index 4f73be2..e691dee 100644
--- a/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri.csproj
+++ b/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri.csproj
@@ -48,7 +48,7 @@
<ItemGroup>
<NativeReference Include="Library\libHDLSceneSiri.a">
<Kind>Static</Kind>
- <Frameworks>Intents IntentsUI</Frameworks>
+ <Frameworks>Intents IntentsUI Foundation</Frameworks>
</NativeReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />
diff --git a/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Structs.cs b/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Structs.cs
index 0964c4c..7fa07f7 100644
--- a/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Structs.cs
+++ b/Shared.IOS.HDLSceneSiri/Shared.IOS.HDLSceneSiri/Structs.cs
@@ -2,7 +2,7 @@
namespace HDLSceneSiri
{
- [Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)]
+ //[Watch(5, 0), NoTV, Mac(11, 0), iOS(12, 0)]
[Native]
public enum HDLRunSceneIntentResponseCode : long
{
--
Gitblit v1.8.0