Esempio n. 1
0
        private void OnUpdateReceived(IActivatedEventArgs activatedEventArgs)
        {
            // Handle toast activation
            if (activatedEventArgs is ToastNotificationActivatedEventArgs)
            {
                var toastActivationArgs = activatedEventArgs as ToastNotificationActivatedEventArgs;

                // Parse the query string
                QueryString args = QueryString.Parse(toastActivationArgs.Argument);

                var not = new PlainNotification()
                {
                    Uid = Convert.ToUInt32(args["uid"])
                };

                // See what action is being requested
                switch (args["action"])
                {
                case "positive":
                    OnAction(not, true);
                    break;

                case "negative":
                    OnAction(not, false);
                    break;
                }
            }
        }
Esempio n. 2
0
        private async void AncsManagerOnOnNotification(PlainNotification o)
        {
            await this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                this.DataList.Add(o);
            });


            Show(new ToastContent()
            {
                Visual = new ToastVisual()
                {
                    TitleText = new ToastText()
                    {
                        Text = o.Title
                    },
                    BodyTextLine1 = new ToastText()
                    {
                        Text = o.Message
                    }
                },

                Scenario = ToastScenario.Default,

                Actions = new ToastActionsCustom()
                {
                    Buttons =
                    {
                        new ToastButtonDismiss("Ok")
                    }
                }
            });
        }
Esempio n. 3
0
        private async void DataSourceCharacteristicOnValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
        {
            var stream = args.CharacteristicValue.AsStream();
            var br     = new BinaryReader(stream);

            var cmdId    = br.ReadByte();
            var notUid   = br.ReadUInt32();
            var attr1    = (NotificationAttribute)br.ReadByte();
            var attr1len = br.ReadUInt16();
            var attr1val = br.ReadChars(attr1len);
            var attr2    = (NotificationAttribute)br.ReadByte();
            var attr2len = br.ReadUInt16();
            var attr2val = br.ReadChars(attr2len);

            EventFlags?flags = null;

            if (FlagCache.ContainsKey(notUid))
            {
                flags = FlagCache[notUid];
            }

            var not = new PlainNotification()
            {
                EventFlags = flags,
                Uid        = notUid,
                Title      = new string(attr1val),
                Message    = new string(attr2val)
            };

            OnNotification?.Invoke(not);
        }
Esempio n. 4
0
        public async void OnAction(PlainNotification notification, bool positive)
        {
            //Relay notification action back to device
            var not = new NotificationActionData
            {
                CommandId       = 0x02, //CommandIDPerformNotificationAction
                NotificationUID = notification.Uid,
                ActionId        = positive ? ActionId.Positive : ActionId.Negative
            };

            var bytes = StructureToByteArray(not);

            try
            {
                var status =
                    await
                    this.ControlPointCharacteristic.WriteValueAsync(bytes.AsBuffer(),
                                                                    GattWriteOption.WriteWithResponse);
            }
            catch (Exception)
            {
            }
        }
        private async void AncsManagerOnOnNotification(PlainNotification o)
        {
            XmlDocument toastXml = null;

            ToastVisual toastVisual = new ToastVisual()
            {
                BindingGeneric = new ToastBindingGeneric()
                {
                    Children =
                    {
                        new AdaptiveText()
                        {
                            Text = o.Title
                        },
                        new AdaptiveText
                        {
                            Text = o.Message
                        }
                    }
                },
            };

            // toast actions
            ToastActionsCustom toastActions = new ToastActionsCustom();

            switch (o.CategoryId)
            {
            case CategoryId.IncomingCall:
                //toastVisual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo() { Source = "Assets/iOS7_App_Icon_Phone.png" };
                toastActions.Buttons.Add(new ToastButton("Answer", new QueryString()
                {
                    { "action", "positive" },
                    { "uid", o.Uid.ToString() }
                }.ToString())
                {
                    ActivationType = ToastActivationType.Foreground
                });

                //toastVisual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo() { Source = "Assets/iOS7_App_Icon_Phone.png" };
                toastActions.Buttons.Add(new ToastButton("Dismiss", new QueryString()
                {
                    { "action", "negative" },
                    { "uid", o.Uid.ToString() }
                }.ToString())
                {
                    ActivationType = ToastActivationType.Foreground
                });

                break;

            case CategoryId.MissedCall:
                //toastVisual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo() { Source = "Assets/iOS7_App_Icon_Phone.png" };
                toastActions.Buttons.Add(new ToastButton("Dial", new QueryString()
                {
                    { "action", "positive" },
                    { "uid", o.Uid.ToString() }
                }.ToString())
                {
                    ActivationType = ToastActivationType.Foreground
                });

                //toastVisual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo() { Source = "Assets/iOS7_App_Icon_Phone.png" };
                toastActions.Buttons.Add(new ToastButton("Dismiss", new QueryString()
                {
                    { "action", "negative" },
                    { "uid", o.Uid.ToString() }
                }.ToString())
                {
                    ActivationType = ToastActivationType.Foreground
                });
                break;

            case CategoryId.Voicemail:
                //toastVisual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo() { Source = "Assets/iOS7_App_Icon_Phone.png" };
                toastActions.Buttons.Add(new ToastButton("Dial", new QueryString()
                {
                    { "action", "positive" },
                    { "uid", o.Uid.ToString() }
                }.ToString())
                {
                    ActivationType = ToastActivationType.Foreground
                });

                toastActions.Buttons.Add(new ToastButtonDismiss());
                break;

            case CategoryId.Email:
                //toastVisual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo() { Source = "Assets/iOS7_App_Icon_Email.png" };
                toastActions.Buttons.Add(new ToastButtonDismiss());
                break;

            default:
                toastActions.Buttons.Add(new ToastButtonDismiss());
                break;
            }

            ToastContent toastContent = new ToastContent()
            {
                Visual   = toastVisual,
                Scenario = ToastScenario.Default,
                Actions  = toastActions,
            };

            toastXml = toastContent.GetXml();

            ToastNotification toastNotification = new ToastNotification(toastXml)
            {
                ExpirationTime = DateTime.Now.AddMinutes(5)
            };

            ToastNotificationManager.CreateToastNotifier().Show(toastNotification);

            // Old stuff
            await this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                this.DataList.Add(o);
            });
        }