Dpedrinha
Dpedrinha

Reputation: 4220

How to avoid ScheduledToastNotification from launching the App on UWP?

I have a kind of alarm on my App.

It's working fine, but when it finishes all I want is to pop-up the notification. I have a button to dismiss and another one to snooze. Both of them open the app once tapped. I don't want this behavior. All I need is to snooze it or dismiss it and that's it.

Is it possible?

Here is how I'm doing it:

    var xmlString = @"<toast launch='args' scenario='alarm'>
        <visual>
            <binding template='ToastGeneric'>
                <text>" + alertAction + @"</text>
                <text>" + alertBody + @"</text>
            </binding>
        </visual>
        <actions>

            <action arguments = 'snooze'
                    content = 'Snooze' />

            <action arguments = 'dismiss'
                    content = 'Dismiss' />

        </actions>
    </toast>";
    var doc = new Windows.Data.Xml.Dom.XmlDocument();
    doc.LoadXml(xmlString);
    var toast = new ScheduledToastNotification(doc, DateTimeOffset.Now.AddMinutes(durationInMinutes), new TimeSpan(0, 0, 300), 5);        
    toast.Id = id;
    ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);

Upvotes: 0

Views: 331

Answers (1)

Tea Nguyen
Tea Nguyen

Reputation: 78

Your current action will generate a ToastButton type, which is normal activationType & will active the app when tapped. If you don't want to active the app, declare activationType to system.

Try to use

 <actions hint-systemCommands = 'SnoozeAndDismiss' />

or add activationType="system" in each of action

<actions>

        <action activationType="system"
                arguments = 'snooze'
                content = 'Snooze' />

        <action activationType="system"
                arguments = 'dismiss'
                content = 'Dismiss' />

</actions>

Upvotes: 2

Related Questions