From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Home.Ios/AppDelegate.cs |  240 +++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 188 insertions(+), 52 deletions(-)

diff --git a/ZigbeeApp/Home.Ios/AppDelegate.cs b/ZigbeeApp/Home.Ios/AppDelegate.cs
old mode 100755
new mode 100644
index d9396e2..3db7bf3
--- a/ZigbeeApp/Home.Ios/AppDelegate.cs
+++ b/ZigbeeApp/Home.Ios/AppDelegate.cs
@@ -1,4 +1,4 @@
-锘縰sing System;
+锘縰sing System;
 using Foundation;
 using Microsoft.AppCenter;
 using Microsoft.AppCenter.Analytics;
@@ -25,8 +25,15 @@
 
         public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
         {
-            //base.FinishedLaunching(application, launchOptions);
+            //鍏ㄨ閫氳皟鐢‵inishedLaunch
+            Shared.IOS.HDLFVSDK.Video.FVapplication(application,new NSDictionary());
+
+
+            Shared.Application.IsGpsEnable = false;
+            Shared.Application.IsMusicEnable = false;
+            base.FinishedLaunching(application, launchOptions);
             Shared.Application.FontSize = 12;
+            Shared.Application.IsUsePingFang = true;
             Window = new UIWindow(UIScreen.MainScreen.Bounds);
             rootViewController = new UINavigationController(new GateWay.Ios.MainViewController()) { NavigationBarHidden = true };
             Window.RootViewController = rootViewController;
@@ -36,11 +43,16 @@
 
             DeviceTokenAction += (deviceToken) =>
             {
-                Shared.Common.Config.Instance.RegistrationID = deviceToken;
+                if (!string.IsNullOrEmpty(deviceToken))
+                {
+                    Shared.Common.Config.Instance.RegistrationID = deviceToken;
+                    Shared.Common.Config.Instance.Save();
+                }
             };
             haveToSignOut = false;
             if (launchOptions != null)
             {
+
                 // check for a remote notification
                 if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                 {
@@ -50,33 +62,50 @@
                         NSString key_hiddenJson = new NSString("HiddenJson");
                         if (userInfo.ContainsKey(key_hiddenJson))
                         {
-                            NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
-                            if (hiddenJsonDic != null)
-                            {
-                                NSString key_Offline = new NSString("Offline");
-                                if (hiddenJsonDic.ContainsKey(key_Offline))
+                            var hiddenJson = userInfo["HiddenJson"].ToString();
+                            if (!string.IsNullOrEmpty(hiddenJson))
+                            {
+                                if (hiddenJson.Contains("cmtID"))
                                 {
-                                    string signOut = hiddenJsonDic["Offline"].ToString();
 
-                                    if (signOut == "0")
+                                    ///鐩墠鏍规嵁杩欎釜鍒ゆ柇鏄惁鏄彲瑙嗗璁叉暟鎹�
+                                    // VideoMethod(hiddenJson);
+                                }
+                                else
+                                {
+
+                                    NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
+                                    if (hiddenJsonDic != null)
                                     {
-                                        //涓嶄笅绾�
-                                    }
-                                    else
-                                    {
-                                        //鏍囪涓嬬嚎
-                                        haveToSignOut = true;
-                                    }
-                                }
+                                        NSString key_Offline = new NSString("Offline");
+                                        if (hiddenJsonDic.ContainsKey(key_Offline))
+                                        {
+                                            string signOut = hiddenJsonDic["Offline"].ToString();
 
+                                            if (signOut == "0")
+                                            {
+                                                //涓嶄笅绾�
+                                            }
+                                            else
+                                            {
+                                                //鏍囪涓嬬嚎
+                                                haveToSignOut = true;
+                                            }
+                                        }
+
+                                    }
+                                }
                             }
+
+
                         }
 
                     }
                 }
             }
             AppCenter.Start("0ca801a2-742b-42fb-ba10-7ba4391371aa", typeof(Analytics), typeof(Crashes));
-            GDMapKit.setGDApiKey("866fae25f336bc8d9a79b1d19267fffb");//楂樺痉鍦板浘key
+            GDMapKit.setGDApiKey("3889cdfa4ef10c0d43348ffa2c1017c8");//楂樺痉鍦板浘key
+
             return true;
         }
 
@@ -86,8 +115,11 @@
         }
         public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
         {
+
             if (userInfo == null)
             {
+                //var alert = new Alert("", "userInfo涓虹┖", "");
+                //alert.Show();
                 return;
             }
             Console.WriteLine(userInfo);
@@ -95,27 +127,50 @@
             if (application.ApplicationState == UIApplicationState.Active || application.ApplicationState == UIApplicationState.Background)
             {
                 NSString key_hiddenJson = new NSString("HiddenJson");
+                //var alert1 = new Alert("", "鏀跺埌鎺ㄩ�佷簡", "");
+                //alert1.Show();
                 if (userInfo.ContainsKey(key_hiddenJson))
                 {
-                    NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
-                    if (hiddenJsonDic == null)
-                    {
-                        return;
-                    }
-                    NSString key_Offline = new NSString("Offline");
-                    if (hiddenJsonDic.ContainsKey(key_Offline))
-                    {
-                        string signOut = hiddenJsonDic["Offline"].ToString();
 
-                        if (signOut == "0")
+                    var hiddenJson = userInfo["HiddenJson"].ToString();
+
+                    //var alert = new Alert("", hiddenJson, "");
+                    //alert.Show();
+
+                    if (string.IsNullOrEmpty(hiddenJson))
+                    {
+                        return;
+                    }
+
+                    if (hiddenJson.Contains("cmtID"))
+                    {
+
+                        ///鐩墠鏍规嵁杩欎釜鍒ゆ柇鏄惁鏄彲瑙嗗璁叉暟鎹�
+                        //VideoMethod(hiddenJson);
+                    }
+                    else
+                    {
+
+                        NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
+                        if (hiddenJsonDic == null)
                         {
-                            //涓嶄笅绾�
+                            return;
                         }
-                        else
+                        NSString key_Offline = new NSString("Offline");
+                        if (hiddenJsonDic.ContainsKey(key_Offline))
                         {
-                            //寮哄埗涓嬬嚎
-                            CommonPage.Instance.SingOut();
-                            CommonPage.Instance.ShowErrorInfoAlert(Shared.R.MyInternationalizationString.YouHaveBeenSignOut);
+                            string signOut = hiddenJsonDic["Offline"].ToString();
+
+                            if (signOut == "0")
+                            {
+                                //涓嶄笅绾�
+                            }
+                            else
+                            {
+                                //寮哄埗涓嬬嚎
+                                CommonPage.Instance.SingOut();
+                                CommonPage.Instance.ShowErrorInfoAlert(Shared.R.MyInternationalizationString.uHadBeenLoginAndOffLine);
+                            }
                         }
                     }
                 }
@@ -125,34 +180,87 @@
                 NSString key_hiddenJson = new NSString("HiddenJson");
                 if (userInfo.ContainsKey(key_hiddenJson))
                 {
-                    NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
-                    if (hiddenJsonDic == null)
-                    {
-                        return;
-                    }
-                    NSString key_Offline = new NSString("Offline");
-                    if (hiddenJsonDic.ContainsKey(key_Offline))
-                    {
-                        string signOut = hiddenJsonDic["Offline"].ToString();
-
-                        if (signOut == "0")
+
+                    var hiddenJson = userInfo["HiddenJson"].ToString();
+                    if (string.IsNullOrEmpty(hiddenJson)) {
+                        return;
+                    }
+
+                    if (hiddenJson.Contains("cmtID"))
+                    {
+                        ///鐩墠鏍规嵁杩欎釜鍒ゆ柇鏄惁鏄彲瑙嗗璁叉暟鎹�
+                        //VideoMethod(hiddenJson);
+                    }
+                    else
+                    {
+
+                        NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
+                        if (hiddenJsonDic == null)
                         {
-                            //涓嶄笅绾�
+                            return;
                         }
-                        else
+                        NSString key_Offline = new NSString("Offline");
+                        if (hiddenJsonDic.ContainsKey(key_Offline))
                         {
-                            //鏍囪涓嬬嚎
-                            haveToSignOut = true;
+                            string signOut = hiddenJsonDic["Offline"].ToString();
+
+                            if (signOut == "0")
+                            {
+                                //涓嶄笅绾�
+                            }
+                            else
+                            {
+                                //鏍囪涓嬬嚎
+                                haveToSignOut = true;
+                            }
                         }
                     }
                 }
 
             }
             completionHandler(UIBackgroundFetchResult.NewData);
+        }
+        /// <summary>
+        /// ios閫氱煡鏍忕偣鍑绘墦寮�鍙瀵硅鐨勬柟娉�
+        /// </summary>
+        /// <param name="hiddenJson">浜戠鎺ㄨ繃鏉ョ殑鏁版嵁</param>
+        private  void VideoMethod(string hiddenJson)
+        {
+
+            var json = Newtonsoft.Json.Linq.JObject.Parse(hiddenJson);
+            if (json == null)
+            {
+                return;
+            }
+            GateWay.Ios.ESVideoInfo eSVideoInfo = new GateWay.Ios.ESVideoInfo();
+            if (json["uuid"].ToString().Contains(","))
+            {
+                var uuid = json["uuid"].ToString().Split(',');
+                eSVideoInfo.ESVideoUUID = uuid[0];
+            }
+            else
+            {
+                eSVideoInfo.ESVideoUUID = json["uuid"].ToString();
+            }
+
+            eSVideoInfo.DeviceName = Language.StringByID(Shared.R.MyInternationalizationString.theOutdoorUnit);
+            eSVideoInfo.ESRoomID = int.Parse(json["roomno"].ToString());
+            if (!string.IsNullOrEmpty(json["unitno"].ToString()))
+            {
+                string str = json["unitno"].ToString();
+                string str1 = str.Substring(0, 2).TrimStart('0');
+                string str2 = str.Substring(2, 2).TrimStart('0');
+                eSVideoInfo.RoomName = str1 + Language.StringByID(Shared.R.MyInternationalizationString.dong) + str2 + Language.StringByID(Shared.R.MyInternationalizationString.unit);
+            }
+            GateWay.Ios.ESVideo.ShowESvideoVideoIntercom(eSVideoInfo);
+
+            //var url = "https://global.hdlcontrol.com/HangZhouHdlCloudApi/VideoIntercom/Answer";
+            //var dd=await Shared.Phone.Device.Logic.Send.HttpWebRequest(url, json.ToString(), "POST", 3, true);
         }
 
         public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
         {
+
             Console.WriteLine(userInfo);
             if (application.ApplicationState == UIApplicationState.Active)
             {
@@ -175,6 +283,7 @@
             // or when the user quits the application and it begins the transition to the background state.
             // Games should use this method to pause the game.
             base.OnResignActivation(application);
+            Shared.IOS.HDLFVSDK.Video.FVapplicationWillResignActive(application);
         }
 
         public override void DidEnterBackground(UIApplication application)
@@ -184,10 +293,15 @@
             //Shared.BusSocket.Stop ();On鍦ㄨ繖閲屽仠姝usSocket
             ZigBee.Common.Application.FindGateWaySocket.Stop();
             base.DidEnterBackground(application);
+            Shared.IOS.HDLFVSDK.Video.FVapplicationDidEnterBackground(application);
         }
 
         public override void WillEnterForeground(UIApplication application)
         {
+            var internetStatus = GateWay.Ios.Reachability.InternetConnectionStatus();
+            Shared.Phone.UserCenter.HdlWifiLogic.Current.NetworkStateChanged((int)internetStatus);
+
+            //ZigBee.Common.Application.FindGateWaySocket.Start();
             // Called as part of the transiton from background to active state.
             // Here you can undo many of the changes made on entering the background.
             System.Console.WriteLine("WillEnterForeground");
@@ -195,8 +309,11 @@
             base.WillEnterForeground(application);
         }
 
+
         public override void OnActivated(UIApplication application)
         {
+            //鍏ㄨ閫氳皟鐢˙ecomeActive
+            Shared.IOS.HDLFVSDK.Video.FVapplicationDidBecomeActive(application);
             // Restart any tasks that were paused (or not yet started) while the application was inactive. 
             // If the application was previously in the background, optionally refresh the user interface.
             base.OnActivated(application);
@@ -205,10 +322,13 @@
             {
                 //寮哄埗涓嬬嚎
                 CommonPage.Instance.SingOut();
-                CommonPage.Instance.ShowErrorInfoAlert(Shared.R.MyInternationalizationString.YouHaveBeenSignOut);
+                CommonPage.Instance.ShowErrorInfoAlert(Shared.R.MyInternationalizationString.uHadBeenLoginAndOffLine);
             }
             //妫�鏌ヨ繛鎺ヨ繙绋�
             //浠g爜
+
+            //娓呴櫎瑙掓爣
+            CommonPage.Instance.clearBadgeNum();
         }
 
         public override void WillTerminate(UIApplication application)
@@ -273,11 +393,27 @@
     public static class QRCode
     {
         static ZXing.Mobile.MobileBarcodeScanner scanner;
-        public static async System.Threading.Tasks.Task ScanQRcode(Action<string> action, string topText = "", string bottomText = "", string cancel = "Cancel")
+        public static async System.Threading.Tasks.Task ScanQRcode(Action<string> action, string cancel = "鍙栨秷", string flashText = "闂厜鐏�", string titleText = "浜岀淮鐮佹壂鎻�")
         {
             if (scanner == null)
             {
-                scanner = new ZXing.Mobile.MobileBarcodeScanner(Home.IOS.AppDelegate.rootViewController) { FlashButtonText = "", TopText = topText, BottomText = bottomText, CancelButtonText = cancel };
+                var mZXingOverlayView = new Home.IOS.ZXingOverlayView(cancel, flashText, titleText);
+                scanner = new ZXing.Mobile.MobileBarcodeScanner(Home.IOS.AppDelegate.rootViewController) { FlashButtonText = flashText, TopText = titleText, BottomText = "", CancelButtonText = cancel };
+                scanner.UseCustomOverlay = true;
+
+                scanner.CustomOverlay = mZXingOverlayView;
+                var bOn = false;
+                mZXingOverlayView.OnCancel += () => {
+
+                    scanner?.Cancel();
+                };
+
+                mZXingOverlayView.OnTorch += () =>
+                {
+                    bOn = !bOn;
+                    scanner?.Torch(bOn);
+                };
+
             }
 
             var result = await scanner.Scan();

--
Gitblit v1.8.0