void Start() { Debug.Log("AppMessaging: Start"); HmsInstanceId inst = HmsInstanceId.GetInstance(); ITask <AAIDResult> idResult = inst.AAID; idResult.AddOnSuccessListener((result) => { AAIDResult AAIDResult = result; Debug.Log("AppMessaging: " + result.Id); AAIDResultAction?.Invoke(result); }).AddOnFailureListener((exception) => { }); OnMessageClicked = OnMessageClickFunction; OnMessageDisplay = OnMessageDisplayFunction; OnMessageDissmiss = OnMessageDissmissFunction; AGConnectAppMessaging appMessaging = AGConnectAppMessaging.Instance; appMessaging.AddOnClickListener(OnMessageClicked); appMessaging.AddOnDisplayListener(OnMessageDisplay); appMessaging.AddOnDismissListener(OnMessageDissmiss); appMessaging.SetForceFetch(); }
public void SetAppMessaging() { try { //Set whether to allow data synchronization from the AppGallery Connect server appMessaging.FetchMessageEnable = true; //Set whether to enable message display appMessaging.DisplayEnable = true; //Get the in-app message data from AppGallery Connect server in real time by force. appMessaging.SetForceFetch(); //Set the appmessage location to bottom of the screen appMessaging.SetDisplayLocation(Location.Bottom); appMessaging.Trigger("EVENT_ID"); //Subscribe click event of app meessage appMessaging.Click += AppMessaging_Click; //Subscribe display event of app meessage appMessaging.Display += AppMessaging_Display; //Subscribe dismiss event of app meessage appMessaging.Dismiss += AppMessaging_Dismiss; //Subscribe error event of app meessage appMessaging.Error += AppMessaging_Error; Console.WriteLine("AppMessaging configuration success"); } catch (Exception ex) { Console.WriteLine("AppMessaging configuration failed: " + ex.ToString()); } }