Windows Phone 8.1 Universal App, BackgroundTask is not running when trigger is set as Pushnotification -


i have created backgroundtask raw push notification , followed below steps. backgroundtaks not running when trigger set pushnotificationtrigger.

  1. i have created portable windows runtime component project.
  2. create class mytask, here complete code of mytask class

    namespace windowsruntimecomponent1 {     public sealed class mytask : ibackgroundtask       {         public void run(ibackgroundtaskinstance taskinstance)         {             rawnotification rawnotification = taskinstance.triggerdetails rawnotification;          }       } } 
  3. added reference of windows runtime component project windows phone 8.1 universal app.

  4. package.appxmanifest has below declaration enter image description here

  5. the backgroundtask registration has below code executes on click of button.

    private async void registerbackgroundtask(object sender, routedeventargs e) {     var access = await backgroundexecutionmanager.requestaccessasync();      if (access != backgroundaccessstatus.denied)     {         backgroundtaskbuilder builder = new backgroundtaskbuilder();         builder.addcondition(new systemcondition(systemconditiontype.internetavailable));         builder.name = "pushtasktest";         builder.taskentrypoint = typeof(windowsruntimecomponent1.mytask).fullname;         builder.settrigger(new pushnotificationtrigger());          builder.register();     } } 
  6. code register pushnotificationchannel

    protected async override void onnavigatedto(navigationeventargs e) {     var channel = await pushnotificationchannelmanager.createpushnotificationchannelforapplicationasync();      notificationhub hub = new notificationhub(       "testmobileservicehub",       "endpoint=sb://testmobileservicehub-ns.servicebus.windows.net/;sharedaccesskeyname=defaultlistensharedaccesssignature;sharedaccesskey=wr6fstfuc+1ppnspujlcv3t57upfxlu=");      var result = await hub.registernativeasync(channel.uri);   } 
  7. now when running app, lifecycle events showing "no background tasks"

enter image description here

  1. but when put systemtrigger, lifecycle events showed up.

enter image description here

can 1 please why backgroundtask not running in case of push notification trigger?


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -