locked
Dialog to Allow deny for Timer based background task

    Question

  • Hi,

    I am using a timer based background task, which works sometime and sometimes didn't(means run method did not get called). I have declared all permission required in App manifest file and made background task as a separate winmd project.

    I observed that, when i install a fresh build on any machine and launch my app...it shows me a dialog to Allow or Deny for timer based background task, but when i reinstall the same build than it did not show me that dialog, though my all timer based background tasks get registered successfully. Verified this through permission in charm bar and also by implementing logger.

    What i have observed is, when i get this dialog than my background task works fine, but when i did not get this dialog than it stops working.

    Even after reinstalling App, i see my last updates reflecting on live tile which i updated before uninstalling App.

    Please help.


    Regards, Rahul Jaiswal

    Friday, June 20, 2014 12:26 PM

All replies

  • Hi,

    Would you enable Lock screen access in your app? You should enable it in your app by Settings > Permissions > Lock screen : On. Please see the link below:

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh779720.aspx

    And the BackgroundExecutionManager has a method that can be called to prompt a user to grant access to the lock screen.  The user can allow access from the modal dialog or deny access.  If denied, then the user will have to use the Settings to enable it later.  Once invoked, the user will not be prompted again unless the app is uninstalled and reinstalled. You can have a method that is called from my MainPage OnNavigated handler:

    private async Task IntitializeBackgroundTaskAsync()
            {
                Debug.WriteLine("Initializing Background Task");
                await BackgroundExecutionManager.RequestAccessAsync();
               
    
                if (TaskIsRegistered("QVBackgroundTaska") == false)
                {
                    BackgroundTaskRegistration task = registerBackgroundTask();
                }
                
            }

    And refer to the link below:

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977059.aspx

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, June 23, 2014 6:47 AM
  • Hi Anne,

    I already did this. I have observed that problem is with uninstall. When i uninstall my app and install it again than this dialog does not appear and the reason behind this is:

    After uninstalling App, i went to Change PC Setting => PC and devices => Lock screen => Lock screen apps. I found that sometimes i shows me my App logo though App is  no more installed on device and sometimes it shows me "+" sign and when i move my cursor over "+" sign than it shows me my App Package name.  See below image. this issue get solved when i manually assign permission to any other app on that position, than everything works fine.

    It seems that there is some issue with uninstall.


    Regards, Rahul Jaiswal

    Monday, June 23, 2014 11:26 AM
  • Hi Anne,

    By marking my Post as Answer, what should i consider this.

    Its a Windows bugs or what? Please let me know.


    Regards, Rahul Jaiswal

    Friday, June 27, 2014 6:50 AM
  • Hi,

    Sorry for that. By the words in your reply:

    this issue get solved when i manually assign permission to any other app on that position, than everything works fine.

    I think your problem can resolve. I find a link below:

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh779720.aspx

    There are some words in the link:

    Note  An app is allowed to ask for lock screen access only once. The user can choose only one of the two options, so their preference will have been stated (although they can also dismiss the dialog without making a choice). Further calls to requestAccessAsync will be ignored.

    So when you uinstall and then reinstall a app. The app have a same id and windows think it is a same app so the dialog cannot display. You should manually set in the PC seetings. The link below also describe this.

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.



    Friday, June 27, 2014 9:36 AM
  • Hi Anne,

    You mean, this is the expected behavior for lock screen access Apps in Windows, when we uninstall and reinstall it again.

    "So when you uninstall and then reinstall a app. The app have a same id and windows think it is a same app so the dialog cannot display."

    But why that position in lock screen settings still shows the package of the App which is no more installed on device. Even because of this when we reinstall App, my all timer based background task does not get triggered though they get registered successfully.

    Even we have seen similar problem with live tile also, it shows last updates which we made on live tile, after reinstalling app.


    Regards, Rahul Jaiswal


    Monday, June 30, 2014 8:47 AM
  • Hi Anne,

    You mean, this is the expected behavior for lock screen access Apps in Windows, when we uninstall and reinstall it again.

    "So when you uninstall and then reinstall a app. The app have a same id and windows think it is a same app so the dialog cannot display."

    But why that position in lock screen settings still shows the package of the App which is no more installed on device. Even because of this when we reinstall App, my all timer based background task does not get triggered though they get registered successfully.

    You can download the App from below link and check the behavior. We have tested this on 5 machine and found same behavior on all of the machine.

    Even we have seen similar problem with live tile also, it shows last updates which we made on live tile, after reinstalling app.


    Regards, Rahul Jaiswal


    Monday, June 30, 2014 8:47 AM
  • Hi Anne,

    Please let me know, if you have any update on this.


    Regards, Rahul Jaiswal

    Monday, July 7, 2014 6:23 AM