c# - Push Notification Trigger on Windows Phone 8.1 Silverlight -


i'm working on "feature" push notification trigger available in windows phone 8.1. goal make work windows phone silverlight 8.1 project. far know, should work based on reading.

after 2 days, i'm totally stuck. no matter i'm trying. when send raw notification app, app canceled , i'm windows menu.

the output : program '[1852] backgroundtaskhost.exe' has exited code 1 (0x1). program '[2712] aghost.exe' has exited code 1 (0x1).

state :

  • the app receives notification. trigger onpushnotificationreceived. (after event, app canceled)
  • the push notification task declared , entry point defined push.notification.
  • i create windows runtime component windows phone 8.1 in order run background task.
  • the background task registered.

private async void registerbackgroundtask() {     unregisterbackgroundtask(taskname);     backgroundaccessstatus backgroundstatus = await backgroundexecutionmanager.requestaccessasync();     if (backgroundstatus != backgroundaccessstatus.denied && backgroundstatus != backgroundaccessstatus.unspecified)     {         try         {             backgroundtaskbuilder taskbuilder = new backgroundtaskbuilder();             taskbuilder.name = taskname;             pushnotificationtrigger trigger = new pushnotificationtrigger();             taskbuilder.settrigger(trigger);             taskbuilder.taskentrypoint = "push.notification";             backgroundtaskregistration task = taskbuilder.register();         }         catch (exception ex)         { }     } } 
  • the background task :

public sealed class notification {     public void run(ibackgroundtaskinstance taskinstance)     {         debug.writeline("background starting...");         debug.writeline("background completed!");     } } 

i have no clue i'm doing wrong. there make works ? (not in theory) information, have 2 warnings worrying me :

  • i have mismatch in process architecture in 2 projects. windows phone project use "any cpu" (can"t change that). windows runetime component project use "arm". if use "any cpu" wor winrt, got errror : /platform:anycpu32bitpreferred can used /t:exe, /t:winexe , /t:appcontainerexe
  • there conflict on dependent assembly of 2 projects. seems

found conflicts between different versions of same dependent assembly. in visual studio, double-click warning (or select , press enter) fix conflicts; otherwise, add following binding redirects "runtime" node in application configuration file:

thanks in advance

i did make works.

there error in initial code forgot implement ibackgroundtask :

public sealed class notification : ibackgroundtask {     public void run(ibackgroundtaskinstance taskinstance)     {         debug.writeline("background starting...");         debug.writeline("background completed!");     } } 

and had make task async...

public async void run(ibackgroundtaskinstance taskinstance) {     backgroundtaskdeferral deferral = taskinstance.getdeferral();     // perform async task , call deferral  complete     await test();     deferral.complete(); }  private static async task test() {     //todo await } 

hope this'll someone.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -