From 207b7261e989e4271578eddb933b33ba008379bb Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 22 十一月 2021 14:14:25 +0800
Subject: [PATCH] 1

---
 HDL-ON_iOS/AppDelegate.cs |   80 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 78 insertions(+), 2 deletions(-)

diff --git a/HDL-ON_iOS/AppDelegate.cs b/HDL-ON_iOS/AppDelegate.cs
index 8ea5561..81d1d57 100644
--- a/HDL-ON_iOS/AppDelegate.cs
+++ b/HDL-ON_iOS/AppDelegate.cs
@@ -9,6 +9,9 @@
 using Microsoft.AppCenter.Crashes;
 using HDL_ON.UI;
 using HDL_ON.DAL.Server;
+using Intents;
+using Other.Siri;
+using HDLSceneSiri;
 
 namespace SharedMethod
 {
@@ -59,7 +62,7 @@
         //    // If not required for your application you can safely delete this method
         //    return true;
         //}
-        internal static UINavigationController rootViewController;
+        public static UINavigationController rootViewController;
 
         public static void CleanApplicationIconBadgeNumber()
         {
@@ -245,6 +248,7 @@
 
         public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
         {
+            Console.WriteLine("111111111111");
             SetCurrentLanguage();
             //Shared.Application.FontSize = 12;
             //Bugly.Bugly.StartWithAppId("b58fb35436");
@@ -274,7 +278,34 @@
             //{
             //    //RemoteInfo.Current.ReadMsgList(true);
             //}
-          
+
+            #region Siri
+            // Request access to Siri
+            INPreferences.RequestSiriAuthorization((INSiriAuthorizationStatus status) => {
+                // Respond to returned status
+                switch (status)
+                {
+                    case INSiriAuthorizationStatus.Authorized:
+                        break;
+                    case INSiriAuthorizationStatus.Denied:
+                        break;
+                    case INSiriAuthorizationStatus.NotDetermined:
+                        break;
+                    case INSiriAuthorizationStatus.Restricted:
+                        break;
+                }
+            });
+
+            var language = INPreferences.SiriLanguageCode;
+
+            // Take action based on language
+            if (language == "en-US")
+            {
+                // Do something...
+            }
+
+            #endregion
+
             Console.WriteLine("FinishedLaunching");
             return true;
         }
@@ -444,6 +475,51 @@
             HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
         }
 
+
+
+        #region Siri
+        public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
+        {
+            var intent = userActivity.GetInteraction()?.Intent as HDLRunSceneIntent;
+            if (!(intent is null))
+            {
+                HandleIntent(intent);
+                return true;
+            }
+            else if (userActivity.ActivityType == NSUserActivityHelper.ViewMenuActivityType)
+            {
+                HandleUserActivity();
+                return true;
+            }
+            return false;
+        }
+
+        void HandleIntent(HDLRunSceneIntent intent)
+        {
+            var handler = new HDLRunSceneIntentHandlder();
+            handler.HandleRunScene(intent, (response) => {
+                if (response.Code != HDLRunSceneIntentResponseCode.Success)
+                {
+                    Console.WriteLine("Quantity must be greater than 0 to add to order");
+                }
+            });
+        }
+
+        void HandleUserActivity()
+        {
+            //var rootViewController = Window?.RootViewController as UINavigationController;
+            //var orderHistoryViewController = rootViewController?.ViewControllers?.FirstOrDefault() as OrderHistoryTableViewController;
+            //if (orderHistoryViewController is null)
+            //{
+            //    Console.WriteLine("Failed to access OrderHistoryTableViewController.");
+            //    return;
+            //}
+            //var segue = OrderHistoryTableViewController.SegueIdentifiers.SoupMenu;
+            //orderHistoryViewController.PerformSegue(segue, null);
+        }
+        #endregion
+
+
     }
 
 }

--
Gitblit v1.8.0