From 56b417e5bcdf4f34ddcda8c7e56fbac6584e615e Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 07 十二月 2020 17:24:54 +0800
Subject: [PATCH] 2020-12-7-02
---
HDL-ON_iOS/AppDelegate.cs | 216 ++++++++++++++++++++----------------------------------
1 files changed, 80 insertions(+), 136 deletions(-)
diff --git a/HDL-ON_iOS/AppDelegate.cs b/HDL-ON_iOS/AppDelegate.cs
index 0709827..652593e 100644
--- a/HDL-ON_iOS/AppDelegate.cs
+++ b/HDL-ON_iOS/AppDelegate.cs
@@ -8,6 +8,7 @@
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using HDL_ON.UI;
+using HDL_ON.DAL.Server;
namespace SharedMethod
{
@@ -34,6 +35,7 @@
//}
}
+
}
namespace HDL_ON_iOS
@@ -99,16 +101,16 @@
NSUserDefaults.StandardUserDefaults.SetString(DeviceToken, "PushDeviceToken");
string userPhoneName = UIDevice.CurrentDevice.Name;
- OnAppConfig.Instance.PushDeviceToken = DeviceToken;
- OnAppConfig.Instance.PhoneName = userPhoneName;
- OnAppConfig.Instance.SaveUserConfig();
+ UserInfo.Current.PushDeviceToken = DeviceToken;
+ UserInfo.Current.PhoneName = userPhoneName;
+ UserInfo.Current.SaveUserInfo();
}
- if (OnAppConfig.Instance.PushDeviceToken != DeviceToken)
+ if (UserInfo.Current.PushDeviceToken != DeviceToken)
{
string userPhoneName = UIDevice.CurrentDevice.Name;
- OnAppConfig.Instance.PushDeviceToken = DeviceToken;
- OnAppConfig.Instance.PhoneName = userPhoneName;
- OnAppConfig.Instance.SaveUserConfig();
+ UserInfo.Current.PushDeviceToken = DeviceToken;
+ UserInfo.Current.PhoneName = userPhoneName;
+ UserInfo.Current.SaveUserInfo();
}
}
@@ -128,89 +130,13 @@
if (application.ApplicationState == UIApplicationState.Active || application.ApplicationState == UIApplicationState.Background)
{
- NSString key_hiddenJson = new NSString("HiddenJson");
- if (userInfo.ContainsKey(key_hiddenJson))
- {
- 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;
- }
- NSString key_Offline = new NSString("Offline");
- if (hiddenJsonDic.ContainsKey(key_Offline))
- {
- string signOut = hiddenJsonDic["Offline"].ToString();
-
- if (signOut == "0")
- {
- //涓嶄笅绾�
- }
- else
- {
- //寮哄埗涓嬬嚎
- //CommonPage.Instance.SingOut();
- HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
- }
- }
- }
- }
+ HandleNotificationMessageUserInfo(userInfo, false);
}
else
{
- NSString key_hiddenJson = new NSString("HiddenJson");
- if (userInfo.ContainsKey(key_hiddenJson))
- {
-
- 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;
- }
- NSString key_Offline = new NSString("Offline");
- if (hiddenJsonDic.ContainsKey(key_Offline))
- {
- string signOut = hiddenJsonDic["Offline"].ToString();
-
- if (signOut == "0")
- {
- //涓嶄笅绾�
- }
- else
- {
- //鏍囪涓嬬嚎
- haveToSignOut = true;
- }
- }
- }
- }
+ //Inactive
+ HandleNotificationMessageUserInfo(userInfo, false);
}
completionHandler(UIBackgroundFetchResult.NewData);
@@ -269,12 +195,14 @@
Console.WriteLine("OnActivated");
base.OnActivated(application);
- if (haveToSignOut == true)
- {
- //寮哄埗涓嬬嚎
- //CommonPage.Instance.SingOut();
- HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
- }
+ //if (haveToSignOut == true)
+ //{
+ ////寮哄埗涓嬬嚎
+ //UserInfo.Current.LastTime = DateTime.MinValue;
+ //UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//閲嶇疆鐢ㄦ埛澶村儚
+ //UserInfo.Current.SaveUserInfo();
+ //HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
+ //}
}
@@ -342,64 +270,79 @@
}
/// <summary>
- /// 閫�鍑虹櫥褰曟爣璁�
+ /// 澶勭悊閫氱煡娑堟伅
/// </summary>
- bool haveToSignOut;
+ void HandleNotificationMessageUserInfo(NSDictionary userInfo, bool bFinishedLaunching)
+ {
+ try
+ {
+ if (userInfo.ContainsKey(new NSString("aps")))
+ {
+ var aps = userInfo["aps"] as NSDictionary;
+ var alert = aps["alert"] as NSDictionary;
+ var body = alert["body"] as NSString;
+ var title = alert["title"] as NSString;
+ var expandData = "";
+ if (userInfo.ContainsKey(new NSString("expandData")))
+ {
+ expandData = userInfo["expandData"] as NSString;
+ }
+ var pushMes = new JPushMessageInfo()
+ {
+ Title = title,
+ Content = body,
+ Extras = expandData,
+ };
+ System.Console.WriteLine("PushMes title : " + pushMes.Title);
+ System.Console.WriteLine("PushMes message : " + pushMes.Content);
+ System.Console.WriteLine("PushMes extras : " + pushMes.Extras);
+
+ if (bFinishedLaunching)
+ {
+ if (pushMes.Extras != null && pushMes.Extras.Contains("Offline"))
+ {
+ //haveToSignOut = true;
+ //寮哄埗涓嬬嚎
+ UserInfo.Current.LastTime = DateTime.MinValue;
+ UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//閲嶇疆鐢ㄦ埛澶村儚
+ UserInfo.Current.SaveUserInfo();
+ HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
+ }
+ }
+ else
+ {
+ HDLCommon.Current.AdjustPushMessage(pushMes);
+ }
+
+ }
+ }
+ catch
+ {
+
+ }
+ }
+
+ ///// <summary>
+ ///// 閫�鍑虹櫥褰曟爣璁�
+ ///// </summary>
+ //bool haveToSignOut;
/// <summary>
- /// 澶勭悊閫氱煡
+ /// 鍚姩APP 澶勭悊閫氱煡
/// </summary>
/// <param name="launchOptions"></param>
void DealWithPushMes(NSDictionary launchOptions)
{
- haveToSignOut = false;
+ //haveToSignOut = false;
if (launchOptions != null)
{
// check for a remote notification
if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
{
NSDictionary userInfo = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
+
if (userInfo != null)
{
- NSString key_hiddenJson = new NSString("HiddenJson");
- if (userInfo.ContainsKey(key_hiddenJson))
- {
- var hiddenJson = userInfo["HiddenJson"].ToString();
- if (!string.IsNullOrEmpty(hiddenJson))
- {
- if (hiddenJson.Contains("cmtID"))
- {
-
- ///鐩墠鏍规嵁杩欎釜鍒ゆ柇鏄惁鏄彲瑙嗗璁叉暟鎹�
- // VideoMethod(hiddenJson);
- }
- else
- {
-
- NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
- if (hiddenJsonDic != null)
- {
- NSString key_Offline = new NSString("Offline");
- if (hiddenJsonDic.ContainsKey(key_Offline))
- {
- string signOut = hiddenJsonDic["Offline"].ToString();
-
- if (signOut == "0")
- {
- //涓嶄笅绾�
- }
- else
- {
- //鏍囪涓嬬嚎
- haveToSignOut = true;
- }
- }
-
- }
- }
- }
-
-
- }
+ HandleNotificationMessageUserInfo(userInfo, true);
}
}
@@ -409,5 +352,6 @@
}
+
}
--
Gitblit v1.8.0