How to Toast Notification when win app is closed in WP8?

I want to implement Toast and Tile notifications. My notification must meet some criteria, such as it needs to be able to run when my app is closed. For example, a Birthday reminder can run in the background when the app is closed.

Sample I found:

ShellToast toast = new ShellToast();
toast.Title = "Toast Title: ";
toast.Content = "TEST";

The above example works when the app is running. Here is my code:

    private void StartPeriodicAgent()
        // Variable for tracking enabled status of background agents for this app.
        agentsAreEnabled = true;

        // Obtain a reference to the period task, if one exists
        periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask;

        // If the task already exists and background agents are enabled for the
        // application, you must remove the task and then add it again to update 
        // the schedule
        if (periodicTask != null)

        periodicTask = new PeriodicTask(periodicTaskName);

        periodicTask.ExpirationTime = System.DateTime.Now.AddDays(1);

        // The description is required for periodic agents. This is the string that the user
        // will see in the background services Settings page on the device.
        periodicTask.Description = "This demonstrates a periodic task.";

        // Place the call to Add in a try block in case the user has disabled agents.


  private void RunBackgroundWorker()
        //PhoneCallTask calltask = new PhoneCallTask();
        //calltask.PhoneNumber = "03336329631";
        //calltask.DisplayName = "arslan";

        BackgroundWorker backroungWorker = new BackgroundWorker();

        backroungWorker.DoWork += ((s, args) =>

        backroungWorker.RunWorkerCompleted += ((s, args) =>
            this.Dispatcher.BeginInvoke(() =>
                var toast = new ToastPrompt
                    Title = "Simple usage",
                    Message = "Message"


But I don't get any notifications. Can anyone tell me how to set up notifications that work when the app isn't running?


BackgroundWorker is different from scheduled task which you schedule for periodic running.

Add Windows Phone Scheduled Task Agent and in that project write the code logic to invoke the necessary calls for producing a toast.

protected override void OnInvoke(ScheduledTask task)
  Your code for scheduled task running.

Once your code has been completed, you can call NotifyComplete() to indicate once the work of Scheduled Task is over.

Whereas backgroundworker just runs your code in a separate thread and there is no correlation to scheduled task other than the fact that; you can use Background thread in scheduled task.

In order for your logic to be shared across Main Application and Scheduled Task:- Create a separate project and put reusable/shared code inside it. Refer this in main app and scheduled task for sharing/accessing variables.

Make use of IsolatedStorageFile and Mutex in a separate project and share the DLL across both

*Random reference for Schedule task example:*

Need Your Help

AWS Ubuntu via Putty

ubuntu amazon-ec2 putty

I´m having some problems while trying to connect with my Ubuntu server via Putty.

Why is the backspace/del event in an html input breaking my html?

html mobile cordova

I'm doing a Phonegap app and I have this weird issue when doing a backspace or delete key press in the text input. The text input takes 100% width, and if my string is longer than the mobile screen...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.