| 
									
										
										
										
											2025-09-01 06:57:00 +00:00
										 |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace EFSDK | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     using UnityEngine; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public class EFSdkAndroid : MonoBehaviour | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-09-03 08:34:49 +00:00
										 |  |  |  |         private string H5_Load_Succ = "H5_Load_Succ"; | 
					
						
							| 
									
										
										
										
											2025-09-01 06:57:00 +00:00
										 |  |  |  |         private string On_Resume = "onResume"; | 
					
						
							|  |  |  |  |         private string Can_Goback = "canGoback"; | 
					
						
							| 
									
										
										
										
											2025-10-15 08:26:52 +00:00
										 |  |  |  |         private string reqNotifyPermission = "reqNotifyPermission"; | 
					
						
							|  |  |  |  |         private string REQUEST_ADD_WIDGET_RESULT = "requestAddWidgetResult"; | 
					
						
							| 
									
										
										
										
											2025-09-01 06:57:00 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         public void OnReceiverAnd(string message) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             WLoom.QueueOnMainThread(_ => | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Debug.Log("Received message from Android: " + message); | 
					
						
							|  |  |  |  |                 if (message.Contains(On_Resume)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     EFSdk.get().ActionCallback?.Invoke(EFSdk.ActionType.ON_RESUME, message); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (message.Contains(Can_Goback)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     EFSdk.get().mCanGobackAction?.Invoke(bool.Parse(message.Split('#')[1])); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-02 06:37:21 +00:00
										 |  |  |  |                 if (message.Contains(H5_Load_Succ)) | 
					
						
							| 
									
										
										
										
											2025-09-01 06:57:00 +00:00
										 |  |  |  |                 { | 
					
						
							|  |  |  |  |                     //GAM页面加载成功 Gam_Load_Succ@id | 
					
						
							|  |  |  |  |                     string[] parts = message.Split('@'); | 
					
						
							| 
									
										
										
										
											2025-09-02 06:37:21 +00:00
										 |  |  |  |                     EFSdk.get().ActionCallback?.Invoke(EFSdk.ActionType.H5_Load_Succ, parts[1]); | 
					
						
							| 
									
										
										
										
											2025-09-01 06:57:00 +00:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-10-15 08:26:52 +00:00
										 |  |  |  |                 if (message.StartsWith(reqNotifyPermission)) | 
					
						
							| 
									
										
										
										
											2025-09-01 06:57:00 +00:00
										 |  |  |  |                 { | 
					
						
							|  |  |  |  |                     string[] flag = message.Split('#'); | 
					
						
							|  |  |  |  |                     EFSdk.get().mReqNotifyPermissionAction?.Invoke(flag[1].Equals("1")); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-10-15 08:26:52 +00:00
										 |  |  |  |                  | 
					
						
							|  |  |  |  |                 if (message.StartsWith(REQUEST_ADD_WIDGET_RESULT)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     string[] flag = message.Split('#'); | 
					
						
							|  |  |  |  |                     EFSdk.get().actionRequestAddWidgetResult?.Invoke(flag[2].Equals("true")); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-09-01 06:57:00 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (message.StartsWith("Event#")) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     string[] eventKeys = message.Split('#'); | 
					
						
							|  |  |  |  |                     if (eventKeys.Length > 0) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         if (message.Contains("hd_h5_impression")) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             //互动广告展示 | 
					
						
							|  |  |  |  |                             string url = eventKeys[2]; | 
					
						
							|  |  |  |  |                             EFSdk.get().HdH5ImpressionAction?.Invoke(url); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         else if (eventKeys.Length == 2) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             // 只有一个事件key | 
					
						
							|  |  |  |  |                             string eventKey = eventKeys[1]; | 
					
						
							|  |  |  |  |                             EFSdk.get().ActionSDKEventCallback?.Invoke(eventKey, null); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         else if (eventKeys.Length == 3) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             // key-value事件 | 
					
						
							|  |  |  |  |                             string eventKey = eventKeys[1]; | 
					
						
							|  |  |  |  |                             string value = eventKeys[2]; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         else | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             //多属性事件 | 
					
						
							|  |  |  |  |                             string eventKey = eventKeys[1]; | 
					
						
							|  |  |  |  |                             Dictionary<string, string> attrs = new Dictionary<string, string>(); | 
					
						
							|  |  |  |  |                             for (int i = 2; i < eventKeys.Length - 1; i += 2) | 
					
						
							|  |  |  |  |                             { | 
					
						
							|  |  |  |  |                                 string key = eventKeys[i]; | 
					
						
							|  |  |  |  |                                 string value = eventKeys[i + 1]; | 
					
						
							|  |  |  |  |                                 attrs[key] = value; | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                             EFSdk.get().ActionSDKEventCallback?.Invoke(eventKey, attrs); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             }, ""); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |