/// <summary>
        /// Phương thức này sẽ chạy khi Trigger được kích hoạt, không cần gọi tới nó
        /// </summary>
        /// <param name="taskInstance">hệ thống sẽ tự động tạo instance này khi chạy</param>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            //nếu sử dụng một phương thức async nào trong hàm này, hàm run sẽ kết thúc trước khi phương thức đó thực hiện xong.
            // sử dụng defferal để thông báo với hệ thống rằng chưa được phép kết thúc phương thức run
            // nếu bạn không sử dụng phương thức async nào, bạn có thể bỏ defferal đi.
            BackgroundTaskDeferral defferal = taskInstance.GetDeferral();

            // TODO: làm những thứ bạn muốn trong background task ở đây
            // Lưu ý: tất cả các phương thức async nào nằm ngoài khu này đều sẽ không thực hiện được
            string content = (taskInstance.TriggerDetails as Windows.Networking.PushNotifications.RawNotification).Content;

            byte[] contentinBytes = RNAdapterCore.NotificationReceivedAsync(content);

            DotNetCoreUserCodes.UserCodes.OnNotificationReceivedInBGTask(new NotificationInfoForRequesting
            {
                NotificationPreviewContent = contentinBytes
            });

            // sau khi xử lí xong, ta thông báo với hệ thống là hàm run đã thực hiện xong và hệ thống có thể đóng hàm run lại
            //việc này đồng nghĩa với background task sẽ kết thúc
            defferal.Complete();
        }
Ejemplo n.º 2
0
        public static async Task DeleteAllNotificationAsync()
        {
            await RNAdapterCore.DeleteAllNotificationAsync();

            FireNotificationRemovedEvent((await GetAllPreviewData()).Select(n => n.NotificationId));
        }
Ejemplo n.º 3
0
 public async static Task <byte[]> GetNotificationContentAsync(long parameter, string NotificationAccessKey)
 {
     return(await RNAdapterCore.GetNotificationContentAsync(parameter, NotificationAccessKey));
 }
Ejemplo n.º 4
0
 public async static Task <IEnumerable <NotificationInfoForRequesting> > GetAllPreviewData()
 {
     return(await RNAdapterCore.GetAllPreviewContentAsync());
 }
Ejemplo n.º 5
0
 public static async Task Logout(bool keepData)
 {
     await RNAdapterCore.Logout(keepData, Utilities.GetDeviceIMEI());
 }