background mode execution

  1. 8 months ago

    Hi guys,
    Can someone post an example how to use the background modes in the new xojo 2016r4.1 ?
    I dont know why, but the checkboxes in the background modes panel uncheck itself after i save the project.
    Im interested in :

    • playing audio while the app is in the background
    • storing data (location or data from http socket) while in the background

    How to ask for permissions?
    I have this in my info.plist:

    <key>UIBackgroundModes</key>
    <string>audio</string>
    
    <key>NSAppleMusicUsageDescription</key>
    <string>background music permission</string>

    I had to add this plist to the ide, because the background mode checkboxes did nothing.

    Any help is appreciated

  2. 7 months ago

    Yousaf S

    19 Mar 2017 Pre-Release Testers, Xojo Pro
    Edited 7 months ago by Yousaf S

    I have this in my info.plist:

    <key>UIBackgroundModes</key>
    <string>audio</string>
    
    <key>NSAppleMusicUsageDescription</key>
    <string>background music permission</string>

    I had to add this plist to the ide, because the background mode checkboxes did nothing.

    Hi Roland,
    I can't give you much help on the background music side of things but in my experience with setting UIBackgroundModes in info.plist I needed to put the permission key into an array in order to make it work - even if I only wanted one of the keys:

    <key>UIBackgroundModes</key>
    <array><string>audio</string></array>

    or for multiple permissions:

    <key>UIBackgroundModes</key>
    <array><string>fetch</string> <string>remote-notification</string></array>

    This worked for me!

    And yes you are right, the check boxes in the IDE do nothing - not sure if there is a bug reported for this. I found they did not even reliably 'stick', e.g. if you clicked Fetch and then saved your project it would not always be checked when you opened the dialog again at a later stage.

  3. Thank you for your response, but I can't make it work. I used the code you suggested, its in the info.plist file. But I should ask the user to give permissions, how should i do it?

  4. Ulrich B

    20 Mar 2017 Pre-Release Testers, Xojo Pro Europe (Germany, Berlin) · xo...

    @Yousaf S And yes you are right, the check boxes in the IDE do nothing - not sure if there is a bug reported for this. I found they did not even reliably 'stick', e.g. if you clicked Fetch and then saved your project it would not always be checked when you opened the dialog again at a later stage.

    In case you are unsure if a bug report exists, please file one! If it should be a duplicate, it will be combined with the existing one. In any case it’s better to have two than none.
    Thank you!

or Sign Up to reply!