public void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
 {
     if (e.NotificationType == PushNotificationType.Toast)
     {
         this.RefreshOrders();
     }
 }
Ejemplo n.º 2
0
 void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e) => Log.SafeExecute(async() =>
 {
     await this.serviceProvider.Resolve <IPushDelegate>()?.OnReceived(e.RawNotification.Content);
     //this.CurrentRegistrationToken = e.RawNotification.Ur
     this.CurrentRegistrationTokenDate = DateTime.UtcNow;
     e.Cancel = true;
 });
Ejemplo n.º 3
0
 void _channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
 {
     if (PushNotificationReceived != null)
     {
         PushNotificationReceived(sender, args);
     }
 }
Ejemplo n.º 4
0
        private async void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
        {
            String notificationContent = String.Empty;

            switch (e.NotificationType)
            {
            case PushNotificationType.Badge:
                notificationContent = e.BadgeNotification.Content.GetXml();
                break;

            case PushNotificationType.Tile:
                notificationContent = e.TileNotification.Content.GetXml();
                break;

            case PushNotificationType.Toast:
                notificationContent = e.ToastNotification.Content.GetXml();
                break;

            case PushNotificationType.Raw:
                notificationContent = e.RawNotification.Content;
                if (notificationContent == "update")
                {
                    Resolver.Resolve <IEventAggregator>().GetEvent <SyncRequestedEvent>().Publish(new SyncRequestedEventParameters());
                    e.Cancel = true;
                }
                break;
            }

            e.Cancel = true;
        }
Ejemplo n.º 5
0
        private async void Push_PushNotificationReceived(object sender, PushNotificationReceivedEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Message))
            {
                return;
            }

            if (e.CustomData != null && e.CustomData.ContainsKey("action"))
            {
                var action = e.CustomData["action"];
                switch (action)
                {
                // カート情報を更新する
                case "update_cart":
                    await PushCartPageAsync();

                    break;

                // カート情報を更新する
                case "receipt":
                    await PushReceiptPageAsync();

                    break;
                }
            }
        }
Ejemplo n.º 6
0
        private async void Push_PushNotificationReceived(object sender, PushNotificationReceivedEventArgs e)
        {
            // Add the notification message and title to the message:
            StringBuilder pushSummary = new StringBuilder("Push notification received:\n");

            pushSummary.Append($"\tNotification title: {e.Title}\n");
            pushSummary.Append($"\tMessage: {e.Message}");

            // If there is custom data associated width the notification, print the entries:
            if (e.CustomData != null)
            {
                pushSummary.Append("\n\tCustom data:\n");
                foreach (string key in e.CustomData.Keys)
                {
                    pushSummary.Append($"\t\t{key} : {e.CustomData[key]}\n");
                }
            }

            // Log notification summary:
            Logger.Info(pushSummary.ToString());

            // Show push dialog:
            if (e.CustomData.TryGetValue("markdown", out string markdownText))
            {
                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    AppCenterPushDialog dialog = new AppCenterPushDialog(e.Title, markdownText);
                    await UiUtils.ShowDialogAsync(dialog);
                });
            }
        }
Ejemplo n.º 7
0
        private static async void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
        {
            String notificationContent = String.Empty;

            switch (e.NotificationType)
            {
            case PushNotificationType.Badge:
                notificationContent = e.BadgeNotification.Content.GetXml();
                break;

            case PushNotificationType.Tile:
                notificationContent = e.TileNotification.Content.GetXml();
                break;

            case PushNotificationType.Toast:
                notificationContent = e.ToastNotification.Content.GetXml();
                break;

            case PushNotificationType.Raw:
                notificationContent = e.RawNotification.Content;
                break;
            }

            if (_pushCallback != null)
            {
                _pushCallback(notificationContent);
            }
//            e.Cancel = true;
        }
Ejemplo n.º 8
0
        private void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            switch (args.NotificationType)
            {
            case PushNotificationType.Badge:     // badge 通知
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(args.BadgeNotification);
                break;

            case PushNotificationType.Raw:     // raw 通知
                // 当收到推送的 raw 通知时,如果 app 在锁屏,则可以触发后台任务以执行相关的逻辑(PushNotificationTrigger)
                string msg = args.RawNotification.Content;
                break;

            case PushNotificationType.Tile:     // tile 通知
                TileUpdateManager.CreateTileUpdaterForApplication().Update(args.TileNotification);
                break;

            case PushNotificationType.Toast:     // toast 通知
                ToastNotificationManager.CreateToastNotifier().Show(args.ToastNotification);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 9
0
 void OnPushRecieved(object sender, PushNotificationReceivedEventArgs e)
 {
     if (e.CustomData.TryGetValue("CheckIsInstalled", out var s))
     {
         Analytics.TrackEvent("App is still installed");
     }
 }
        private void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            Dictionary <string, object> data = new Dictionary <string, object>();

            if (args.NotificationType == PushNotificationType.Raw)
            {
                foreach (var pair in JsonConvert.DeserializeObject <Dictionary <string, string> >(args.RawNotification.Content))
                {
                    data.Add(pair.Key, pair.Value);
                }
            }
            else if (args.NotificationType == PushNotificationType.Toast)
            {
                foreach (XmlAttribute attribute in args.ToastNotification.Content.DocumentElement.Attributes)
                {
                    data.Add(attribute.Name, attribute.Value);
                }
            }
            else if (args.NotificationType == PushNotificationType.Tile || args.NotificationType == PushNotificationType.TileFlyout)
            {
                foreach (XmlAttribute attribute in args.TileNotification.Content.DocumentElement.Attributes)
                {
                    data.Add(attribute.Name, attribute.Value);
                }
            }

            OnNotificationReceived?.Invoke(CrossPushNotification.Current, new PushNotificationDataEventArgs(data));

            CrossPushNotification.Current.NotificationHandler?.OnReceived(data);
        }
Ejemplo n.º 11
0
 private void OnPushNotificationReceived(object sender, PushNotificationReceivedEventArgs e)
 {
     Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
     {
         Current.MainPage.DisplayAlert(e.Title, e.Message, "ok");
     });
 }
Ejemplo n.º 12
0
        private async void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (e.NotificationType != PushNotificationType.Toast)
                {
                    return;
                }
                e.Cancel = true;

                try
                {
                    txtNotifications.Text += DateTime.Now.ToString() + " Notification: " + (e.ToastNotification.Content.InnerText.Trim()) + "\r\n";
                    // Use ServiceStack.Text.WinRT to get this
                    //                var jsonObj = JsonSerializer.DeserializeFromString<JsonObject>(e.RawNotification.Content);

                    int i = 0;
                    // TODO: Do something with this value now that it works
                }
                catch (Exception err)
                {
                    //Debug.WriteLine(err.Message);
                }
            });
        }
Ejemplo n.º 13
0
        static void channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            string result = args.NotificationType.ToString();

            switch (args.NotificationType)
            {
            case PushNotificationType.Badge:
                result += ": " + args.BadgeNotification.Content.GetXml();
                break;

            case PushNotificationType.Raw:
                result += ": " + args.RawNotification.Content;
                break;

            case PushNotificationType.Tile:
                result += ": " + args.TileNotification.Content.GetXml();
                break;

            case PushNotificationType.TileFlyout:
                result += ": " + args.TileNotification.Content.GetXml();
                break;

            case PushNotificationType.Toast:
                result += ": " + args.ToastNotification.Content.GetXml();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 14
0
 private void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
 {
     if (args.NotificationType == PushNotificationType.Raw)
     {
         args.Cancel = true;
     }
 }
Ejemplo n.º 15
0
 private static void Initialize()
 {
     Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.Instance.ApplicationResuming += (s, e) =>
     {
         WSAApplication.InvokeOnAppThread(new UnityEngine.WSA.AppCallbackItem(() =>
         {
             var arguments = WSAApplication.arguments;
             if (arguments.Contains("appcenterunity"))
             {
                 var idPrefix   = "\"appcenterunity\":\"";
                 var idStartIdx = arguments.IndexOf(idPrefix) + idPrefix.Length;
                 var idString   = arguments.Substring(idStartIdx, _idLength);
                 if (idString != _prevIdString)
                 {
                     _prevIdString = idString;
                     UWPPush.Instance.InstanceCheckLaunchedFromNotification(WSAApplication.arguments);
                 }
             }
         }), false);
     };
     UWPPush.PushNotificationReceived += (sender, e) =>
     {
         var eventArgs = new PushNotificationReceivedEventArgs
         {
             Message    = e.Message,
             Title      = e.Title,
             CustomData = e.CustomData
         };
         HandlePushNotification(eventArgs);
     };
 }
Ejemplo n.º 16
0
        private void OnPushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            if (args.NotificationType == PushNotificationType.Raw)
            {
                args.Cancel = true;
                return;

                if (JsonValue.TryParse(args.RawNotification.Content, out JsonValue node))
                {
                    var notification = node.GetObject();
                    var data         = notification.GetNamedObject("data");

                    if (data.ContainsKey("loc_key"))
                    {
                        var muted = data.GetNamedString("mute", "0") == "1";
                        if (muted)
                        {
                            return;
                        }

                        var custom = data.GetNamedObject("custom", null);
                        if (custom == null)
                        {
                            return;
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
        {
            String notificationContent = String.Empty;

            switch (e.NotificationType)
            {
            case PushNotificationType.Badge:
                notificationContent = e.BadgeNotification.Content.GetXml();
                break;

            case PushNotificationType.Tile:
                notificationContent = e.TileNotification.Content.GetXml();
                break;

            case PushNotificationType.Toast:
                notificationContent = e.ToastNotification.Content.GetXml();
                break;

            case PushNotificationType.Raw:
                notificationContent = e.RawNotification.Content;
                break;
            }

            e.Cancel = true;
        }
        private void HandlePushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            if (args.NotificationType == PushNotificationType.Toast)
            {
                try
                {
                    _pushNotificationsService.HandleForegroundNotification(args.ToastNotification.Content.GetXml());

                    if (_appIsActive)
                    {
                        //app is in focus so we don't need to show toast?
                        args.Cancel = true;
                    }
                }
                catch (Exception e)
                {
                    _analyticsService.LogException(this, e);
                    throw;
                }
            }
            else
            {
                _analyticsService.TraceWarning(this, "Received a non-toast push notification, ignoring...", "Name", args.NotificationType.ToString());
            }
        }
Ejemplo n.º 19
0
        private void OnPushNotificationReceived(object sender, PushNotificationReceivedEventArgs e)
        {
            // Add the notification message and title to the message
            var summary = $"Push notification received:" +
                          $"\n\tNotification title: {e.Title}" +
                          $"\n\tMessage: {e.Message}";

            // If there is custom data associated with the notification,
            // print the entries
            if (e.CustomData != null)
            {
                summary += "\n\tCustom data:\n";
                foreach (var key in e.CustomData.Keys)
                {
                    summary += $"\t\t{key} : {e.CustomData[key]}\n";
                }
            }
            if (this._myOwnNotificationDelegate.didReceiveNotificationInForeground)
            {
                // Present Alert
                //PresentViewController(okAlertController, true, null);
                UIAlertView _error = new UIAlertView("forground", "message recived in foreground", null, "Ok", null);

                _error.Show();
            }



            // Reset the property for next notifications.
            this._myOwnNotificationDelegate.didReceiveNotificationInForeground = false;
            // Send the notification summary to debug output
            System.Diagnostics.Debug.WriteLine(summary);
        }
Ejemplo n.º 20
0
        private void OnPushNotificationReceived(object sender, PushNotificationReceivedEventArgs e)
        {
            // Add the notification message and title to the message
            var summary = "Push notification received:" + $"\n\tNotification title: {e.Title}" +
                          $"\n\tMessage: {e.Message}";

            // If there is custom data associated with the notification,
            // print the entries
            if (e.CustomData != null)
            {
                summary += "\n\tCustom data:\n";
                foreach (var key in e.CustomData.Keys)
                {
                    summary += $"\t\t{key} : {e.CustomData[key]}\n";
                }
            }

            // Send the notification summary to debug output
            Debug.WriteLine(summary);

            // Trên iOS thì dùng alert của system luôn, nên không cần show notify lên nữa.
            // Android thì cần show
            //if (Device.RuntimePlatform == Device.Android)
            //    CrossLocalNotifications.Current.Show(e.Title, e.Message, 0);
        }
Ejemplo n.º 21
0
        private void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            var toast         = args.ToastNotification.Content;
            var pushParameter = toast.SelectSingleNode("toast/@launch").NodeValue;

            /*
             * Push to pull
             */

            toast.SelectSingleNode("toast/visual/binding/text[@id=1]").
            FirstChild.NodeValue = RetrieveSecureNotification(pushParameter);

            ToastNotificationManager.CreateToastNotifier().Show(
                new ToastNotification(toast));

            /*
             * Rich Push
             */

            CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, async() =>
            {
                var dialog = new MessageDialog("There are some news in agenda");
                dialog.Commands.Add(new UICommand()
                {
                    Label   = "Learn more",
                    Invoked = ShowRichPush,
                    Id      = pushParameter
                });
                await dialog.ShowAsync();
            });


            args.Cancel = true;
        }
Ejemplo n.º 22
0
        private async void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
        {
            String notificationContent = String.Empty;

            e.Cancel = true;

            switch (e.NotificationType)
            {
            // Badges are not yet supported and will be added in a future version
            case PushNotificationType.Badge:
                notificationContent = e.BadgeNotification.Content.GetXml();
                break;

            // Tiles are not yet supported and will be added in a future version
            case PushNotificationType.Tile:
                notificationContent = e.TileNotification.Content.GetXml();
                break;

            // The current version of AzureChatr only works via toast notifications
            case PushNotificationType.Toast:
                notificationContent = e.ToastNotification.Content.GetXml();
                XmlDocument toastXml = e.ToastNotification.Content;

                // Extract the relevant chat item data from the toast notification payload
                XmlNodeList toastTextAttributes = toastXml.GetElementsByTagName("text");
                string      username            = toastTextAttributes[0].InnerText;
                string      chatline            = toastTextAttributes[1].InnerText;
                string      chatdatetime        = toastTextAttributes[2].InnerText;

                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    var chatItem = new ChatItem {
                        Text = chatline, UserName = username
                    };
                    // Post the new chat item received in the chat window.
                    // IMPORTANT: If you updated the code above to post new chat lines from
                    //            the current user immediately in the chat window, you will
                    //            end up with duplicates here. You need to filter-out the
                    //            current user's chat entries to avoid these duplicates.
                    items.Add(chatItem);
                    ScrollDown();
                });

                // This is a quick and dirty way to make sure that we don't use speech synthesis
                // to read the current user's chat lines out loud
                if (chatline != lastChatline)
                {
                    ReadText(username + " says: " + chatline);
                }

                break;

            // Raw notifications are not used in this version
            case PushNotificationType.Raw:
                notificationContent = e.RawNotification.Content;
                break;
            }
            //e.Cancel = true;
        }
Ejemplo n.º 23
0
 async void PushNotificationReceived(object sender, PushNotificationReceivedEventArgs e)
 {
     // Rudimentary handle push notifications
     if (e.Title != null || e.Message != null)
     {
         await MainPage?.DisplayAlert(e.Title, e.Message, "Ok");
     }
 }
Ejemplo n.º 24
0
 private async void PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
 {
     if (args.NotificationType == PushNotificationType.Raw)
     {
         Debug.WriteLine($"PushNotificationReceived {args.RawNotification.Content}");
         await HandlePushNotificationAsync(args.RawNotification.Content);
     }
 }
Ejemplo n.º 25
0
        void channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            var test = "test";

            if (args.NotificationType == PushNotificationType.Raw)
            {
            }
        }
Ejemplo n.º 26
0
 async void channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
     {
         var alert = new MessageDialog(args.ToastNotification.Content.InnerText, "New Notification Received In App");
         await alert.ShowAsync();
     });
 }
Ejemplo n.º 27
0
 static void OnPushNotificationReceived(object sender, PushNotificationReceivedEventArgs e)
 {
     Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
     {
         var customData = "{" + string.Join(",", e.CustomData.Select(kv => kv.Key + "=" + kv.Value)) + "}";
         Current.MainPage.DisplayAlert(e.Title, e.Message + "\nCustom data=" + customData, "OK");
     });
 }
Ejemplo n.º 28
0
        private void OnPushNotificationReceived(
            PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
        {
            // In a "real" app, don't rely on toast notifications being sent.
            var msg = args.ToastNotification.Content.InnerText;

            XForms.MessagingCenter.Send <object, string>(this, XamUNotif.App.NotificationReceivedKey, msg);
        }
Ejemplo n.º 29
0
 private void WNS_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
 {
     if (args.NotificationType == PushNotificationType.Raw)
     {
         RawNotification notification = args.RawNotification;
         ToastHelper.showSimpleToast(notification.Content);
     }
 }
Ejemplo n.º 30
0
 async void Push_PushNotificationReceived(object sender, PushNotificationReceivedEventArgs e)
 {
     if (e.Title != null || e.Message != null)
     {
         var dialogService = SimpleIoc.Default.GetInstance <IDialogService>();
         await dialogService?.DisplayDialogAsync(e.Title, e.Message, "Ok");
     }
 }