From f1c3921b08bb22ac6f5db22d620e01d7e8e5c49f Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 30 十二月 2019 13:32:33 +0800
Subject: [PATCH] 2019-12-30-1

---
 ZigbeeApp/GateWay.Ios/AppDelegate.cs |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/ZigbeeApp/GateWay.Ios/AppDelegate.cs b/ZigbeeApp/GateWay.Ios/AppDelegate.cs
old mode 100755
new mode 100644
index 71e2a0f..566871a
--- a/ZigbeeApp/GateWay.Ios/AppDelegate.cs
+++ b/ZigbeeApp/GateWay.Ios/AppDelegate.cs
@@ -4,7 +4,7 @@
 using System;
 using ObjCRuntime;
 using UserNotifications;
-using Shared.Common;
+//using Shared.Common;
 using Microsoft.AppCenter;
 using Microsoft.AppCenter.Analytics;
 using Microsoft.AppCenter.Crashes;
@@ -23,17 +23,20 @@
             set;
         }
 
+        internal static UINavigationController rootViewController;
+
         public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
         {
-            base.FinishedLaunching(application, launchOptions);
+            //base.FinishedLaunching(application, launchOptions);
             Shared.Application.FontSize = 12;
             Window = new UIWindow(UIScreen.MainScreen.Bounds);
-            var root = new UINavigationController(new MainViewController()) { NavigationBarHidden = true };
-            Window.RootViewController = root;
+            rootViewController = new UINavigationController(new MainViewController()) { NavigationBarHidden = true };
+            Window.RootViewController = rootViewController;
             Window.MakeKeyAndVisible();
 
             DeviceTokenAction += (deviceToken) =>
             {
+                
                 Shared.Common.Config.Instance.RegistrationID = deviceToken;
             };
             haveToSignOut = false;
@@ -74,6 +77,7 @@
                 }
             }
             AppCenter.Start("0ca801a2-742b-42fb-ba10-7ba4391371aa", typeof(Analytics), typeof(Crashes));
+            GDMapKit.setGDApiKey("866fae25f336bc8d9a79b1d19267fffb");//楂樺痉鍦板浘key
             return true;
         }
 
@@ -211,4 +215,49 @@
     }
 }
 
- 
+namespace Shared
+{
+    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")
+        {
+            if (scanner == null)
+            {
+                scanner = new ZXing.Mobile.MobileBarcodeScanner(GateWay.Ios.AppDelegate.rootViewController) { FlashButtonText = "", TopText = topText, BottomText = bottomText, CancelButtonText = cancel };
+            }
+
+            var result = await scanner.Scan();
+
+            if (result != null)
+                action?.Invoke(result.Text);
+            else
+                action?.Invoke(null);
+        }
+
+        public static byte[] BytesFromText(string text, int width = 300, int height = 300)
+        {
+            var barcodeWriter = new ZXing.Mobile.BarcodeWriter
+            {
+                Format = ZXing.BarcodeFormat.QR_CODE,
+                Options = new ZXing.Common.EncodingOptions
+                {
+                    Width = width,
+                    Height = height,
+                    Margin = 10
+                }
+            };
+
+            barcodeWriter.Renderer = new ZXing.Mobile.BitmapRenderer();
+            var uiImage = barcodeWriter.Write(text);
+            var data = uiImage.AsJPEG();
+
+            var resultBytes = new byte[data.Length];
+            System.Runtime.InteropServices.Marshal.Copy(data.Bytes, resultBytes, 0, resultBytes.Length);
+
+            return resultBytes;
+        }
+    }
+}
+
+

--
Gitblit v1.8.0