How to use Toast Notification while the app is running on Windows Phone 8.1 Runtime App? -


i'm working on budget manager app. app records expense , income input end user. wanted add functionality app : users able add income/expense happen on regular basis (like every 10 days example).

i thought scheduledtoastnotification solution problem since wanted user approve creation of transaction process complete. problem when app running (even running background) when toastnotification shown on screen, tapping not work intended : launch parameter not passed app. figured out reason because onlaunched event not fired (because app running).

another problem can't make sure working fine since can't debug such behavior : toastnotification relevant when app not running, can't debug not running app. how can know happens when launch app through toastnotification ?

is there solution can me achieve goal ? below code :

public static void createnotification(class.action transaction)     {         var loader = new windows.applicationmodel.resources.resourceloader();         var toastxml = toastnotificationmanager.gettemplatecontent(toasttemplatetype.toasttext02);         var strings = toastxml.getelementsbytagname("text");         strings[0].appendchild(toastxml.createtextnode(loader.getstring("notificationtext")));         strings[1].appendchild(toastxml.createtextnode(transaction.title + " : " + transaction.samount));          ixmlnode toastnode = toastxml.selectsinglenode("/toast");         xmlelement audio = toastxml.createelement("audio");          audio.setattribute("src", "ms-winsoundevent:notification.im");         toastnode.appendchild(audio);          ((xmlelement)toastnode).setattribute("launch", transaction.id.tostring());          var toast = new scheduledtoastnotification(toastxml, transaction.nextoccurence);          toast.id = transaction.id + "";          toastnotificationmanager.createtoastnotifier().addtoschedule(toast);     } 

and how intend use parameter :

int transactionid = 0;          if (int.tryparse((string)e.parameter, out transactionid))         {             var loader = new windows.applicationmodel.resources.resourceloader();              class.action recurentaction = new class.action((from act in actcrud.getactions()                                                                 act.id == transactionid                                                                 select act).firstordefault());              flyout flyer = new flyout();             stackpanel content = new stackpanel();              textblock editmessage = new textblock();             editmessage.fontsize = 20;             editmessage.margin = new thickness(15, 50, 15, 15);             textbox newcategoryname = new textbox();             newcategoryname.fontsize = 20;             newcategoryname.margin = new thickness(15, 15, 15, 15);             button confirmedit = new button();             confirmedit.margin = new thickness(15, 15, 15, 15);              editmessage.text = loader.getstring("entercomment");             newcategoryname.placeholdertext = loader.getstring("entercommentplaceholder");             confirmedit.content = loader.getstring("oktext");             confirmedit.tapped += new tappedeventhandler(delegate(object o, tappedroutedeventargs i)             {                 recurentaction.comment = newcategoryname.text;                 actcrud.addaction(recurentaction);                 mainpage.createnotification((from class.action action in actcrud.getactions()                                              orderby action.id descending                                              select action).first());                  flyer.hide();                 newcategoryname.text = "";             });              content.children.add(editmessage);             content.children.add(newcategoryname);             content.children.add(confirmedit);              flyer.content = content;              messagedialog notificationconfirmation = new messagedialog(loader.getstring("confirmrecurentaction"));             notificationconfirmation.commands.add(new uicommand(loader.getstring("confirm"), (commands) =>             {                 flyer.showat(pivotfintatanana);             }));              notificationconfirmation.commands.add(new uicommand(loader.getstring("donotconfirm"), (commands) =>             {              }));              await notificationconfirmation.showasync();         } 

what i'm looking scheduledtoastnotification send parameters app when 1 running (by forcing fire onlaunched event or through other workarounds).

thanks, regards.

if toast shown while app running, , if tap on toast, onlaunched function indeed called. however, code in onlaunched provided visual studio template checks if content of rootframe null, , if isn't (which should case if app running), shows running instance.

here code skipped if app running:

if (rootframe.content == null) //shouldn't null if app running {       if (!rootframe.navigate(typeof(mainpage), e.arguments))     {         throw new exception("failed create initial page");     } } 

so need add logic in portion of code,

if(e.arguments != null) {     //navigate details page e.arguments }     else if (rootframe.content == null) {     if (!rootframe.navigate(typeof(blankpage1), e.arguments))     {         throw new exception("failed create initial page");     } } 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -