File was renamed from ZigbeeApp/GateWay.Ios/AppDelegate.cs |
| | |
| | | using System;
|
| | | using Foundation; |
| | | using UIKit; |
| | | using Shared; |
| | | using System; |
| | | using ObjCRuntime; |
| | | using UserNotifications; |
| | | using Shared.Common; |
| | | using Microsoft.AppCenter; |
| | | using Microsoft.AppCenter.Analytics; |
| | | using Microsoft.AppCenter.Crashes; |
| | | namespace GateWay.Ios |
| | | using Shared; |
| | | using Shared.Common; |
| | | using Shared.IOS.TBL; |
| | | using UIKit; |
| | | |
| | | namespace Home.IOS |
| | | { |
| | | // The UIApplicationDelegate for the application. This class is responsible for launching the |
| | | // User Interface of the application, as well as listening (and optionally responding) to application events from iOS. |
| | | [Register("AppDelegate")] |
| | | public class AppDelegate : BaseApplicationDelegate |
| | | { |
| | |
| | | //base.FinishedLaunching(application, launchOptions); |
| | | Shared.Application.FontSize = 12; |
| | | Window = new UIWindow(UIScreen.MainScreen.Bounds); |
| | | rootViewController = new UINavigationController(new MainViewController()) { NavigationBarHidden = true }; |
| | | rootViewController = new UINavigationController(new GateWay.Ios.MainViewController()) { NavigationBarHidden = true }; |
| | | Window.RootViewController = rootViewController; |
| | | Window.MakeKeyAndVisible(); |
| | |
|
| | | Shared.IOS.TBL.WXApi.RegisterApp("wx2ec8f53f6fa36e82", "https://hdlcontrol.com/ZigbeeApp/");
|
| | | |
| | | DeviceTokenAction += (deviceToken) => |
| | | { |
| | |
| | | public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo) |
| | | { |
| | | Console.WriteLine(userInfo); |
| | | if (application.ApplicationState == UIApplicationState.Active) { |
| | | if (application.ApplicationState == UIApplicationState.Active) |
| | | { |
| | | System.Console.WriteLine ("ReceivedRemoteNotification1"); |
| | | } else if (application.ApplicationState == UIApplicationState.Background) { |
| | | } |
| | | else if (application.ApplicationState == UIApplicationState.Background) |
| | | { |
| | | System.Console.WriteLine ("ReceivedRemoteNotification2"); |
| | | } else if (application.ApplicationState == UIApplicationState.Inactive) { |
| | | } |
| | | else if (application.ApplicationState == UIApplicationState.Inactive) |
| | | { |
| | | System.Console.WriteLine ("ReceivedRemoteNotification3"); |
| | | } |
| | | } |
| | |
| | | // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground. |
| | | base.WillTerminate(application); |
| | | } |
| | | |
| | | public static Action<string> RespAction; |
| | | public static void WXLogin() |
| | | { |
| | | |
| | | |
| | | var req = new SendAuthReq { Scope = "snsapi_userinfo", State = "ZigbeeApp", OpenID = "0c806938e2413ce73eef92cc3" }; |
| | | WXApi.SendAuthReq(req, rootViewController, null, null); |
| | | |
| | | } |
| | | |
| | | MyWXApiDelegate myWXApiDelegate = new MyWXApiDelegate { }; |
| | | |
| | | class MyWXApiDelegate : WXApiDelegate |
| | | { |
| | | public override void OnReq(BaseReq req) |
| | | { |
| | | |
| | | } |
| | | public override void OnResp(BaseResp resp) |
| | | { |
| | | if (resp is SendAuthResp) |
| | | { |
| | | var sendAuthResp = resp as SendAuthResp; |
| | | switch (sendAuthResp.ErrCode) |
| | | { |
| | | case 0: |
| | | try |
| | | { |
| | | var result = new System.Net.WebClient { }.DownloadString($"https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx2ec8f53f6fa36e82&secret=a08585cd6ff2ce64570b9e7e6525dd8e&code={((SendAuthResp)resp).Code}&grant_type=authorization_code"); |
| | | RespAction?.Invoke(result); |
| | | } |
| | | catch |
| | | { |
| | | RespAction?.Invoke(null); |
| | | } |
| | | break; |
| | | default: |
| | | RespAction?.Invoke(null); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler) |
| | | { |
| | | return WXApi.HandleOpenUniversalLink(userActivity, myWXApiDelegate); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (scanner == null) |
| | | { |
| | | scanner = new ZXing.Mobile.MobileBarcodeScanner(GateWay.Ios.AppDelegate.rootViewController) { FlashButtonText = "", TopText = topText, BottomText = bottomText, CancelButtonText = cancel }; |
| | | scanner = new ZXing.Mobile.MobileBarcodeScanner(Home.IOS.AppDelegate.rootViewController) { FlashButtonText = "", TopText = topText, BottomText = bottomText, CancelButtonText = cancel }; |
| | | } |
| | | |
| | | var result = await scanner.Scan(); |
| | |
| | | { |
| | | Width = width, |
| | | Height = height, |
| | | Margin = 10 |
| | | Margin = 0 |
| | | } |
| | | }; |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |