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 | 89 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 86 insertions(+), 3 deletions(-) diff --git a/HDL-ON_iOS/AppDelegate.cs b/HDL-ON_iOS/AppDelegate.cs index 99caa0e..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,8 +278,34 @@ //{ // //RemoteInfo.Current.ReadMsgList(true); //} - //涓枃鍥藉唴key銆佽嫳鏂囨捣澶杒ey - EZSDK.IOS.EZSDK.InitLibWithAppKey("1aa98a90489b4838b966b57018b4b04b", "1aa98a90489b4838b966b57018b4b04b"); + + #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; } @@ -296,6 +326,7 @@ var expandData = ""; var messageType = ""; var expantContent = ""; + var homeId = ""; if (userInfo.ContainsKey(new NSString("expandData"))) { var expandDataStr = userInfo["expandData"] as NSString; @@ -316,6 +347,12 @@ Utlis.WriteLine("expantContent: " + expantContent); } + if (expandDataNSD.ContainsKey(new NSString("homeId"))) + { + homeId = expandDataNSD["homeId"].ToString(); + Utlis.WriteLine("homeId: " + homeId); + } + } } else @@ -326,6 +363,7 @@ } var pushMes = new JPushMessageInfo() { + HomeId = homeId, Title = title, Content = body, Extras = expandData, @@ -437,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