Search Unity

Run Unity App in background on mobile

Discussion in 'Scripting' started by ReneBaumgartner, Jan 27, 2020.

  1. ReneBaumgartner

    ReneBaumgartner

    Joined:
    May 3, 2014
    Posts:
    13
    Hi fellow devs,

    I want to create a Unity App for Android + iOS which plays an audio file that is pitched by gyrosensor movement (the easy part)

    The audio playback and the pitching via gyrosensor should also work when the app is in background / has no focus (the difficult part)

    It would be ideal that this can be done INSIDE the project, so there is no additional manual step involved when using Unity Cloud Build.

    Any hints appreciated,
    Rene
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    For iOS it is a question whether this is possible at all. IIRC it used to be the case that only music player were allowed to play audio while in background. I'd start from AppStore rules.
    In any case you have to stop Unity playback when in background and implement the stuff as a service or whatever it's called.
     
  3. ReneBaumgartner

    ReneBaumgartner

    Joined:
    May 3, 2014
    Posts:
    13
    @Aurimas-Cernius Thanks a lot for your answer. Apple states in their App Store Review Guidelines under 2.5.4:

    Multitasking apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc. If your app uses location background mode, include a reminder that doing so may dramatically decrease battery life.

    Anybody got some more elaborated hints on the initial question?
     
  4. jipsen

    jipsen

    Joined:
    May 22, 2018
    Posts:
    37
    Did you ever figure this out?