Search Unity

iOS Notifications best on app pause or on app quit?

Discussion in 'iOS and tvOS' started by HeathC, Apr 13, 2020.

  1. HeathC

    HeathC

    Joined:
    Oct 17, 2016
    Posts:
    110
    I recently bought an asset that allows me set up notifications rather easily, so I set up a system to figure which notifications to send and when.

    In doing that I check this system on app pause so notifications will come, and if the player swipes up and closes the app, run the same checks so notifications will come.

    What I discovered is they come twice, because in order to quit an app, it first pauses, so I set it to clear any upcoming notification before running through my system on app quit.

    Is this redundant? This is just my guess as to why they were coming twice, and why that fix worked... but I want to get other iOS developers' opinion on best practices for this...

    Pause? Quit? Both? is there ever a time an app can quit (no way to quit my app without swiping up) without pausing if I don't include an actual way to quit the game?
     
  2. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    This is the normal lifecycle of an iOS app, and exits can happen way later than pauses. It is a good practice to listen for pause and do necessary things as it indicates the user is no longer focusing which for a mobile OS that runs apps mostly fullscreen and suspends unfocused app processes equals to quitting in spirit.

    And unless directly calling exit() system call, there is no way for an app to quit itself in iOS.