Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement exitApp in iOS #2303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bcastro-mcm
Copy link

This pull request introduces a change in the Ionic Capacitor plugin for iOS to ensure a smoother and more reliable app termination process. The updated implementation delays the suspension and exit calls, reducing the risk of premature termination issues.

Changes Introduced

  • Added a delay of 0.2 seconds using DispatchQueue.main.asyncAfter before calling UIApplication.shared.perform(#selector(NSXPCConnection.suspend)).
  • Introduced an additional 0.2-second delay before executing exit(0) to ensure proper app suspension prior to termination.

Reason for the Change

  • This change addresses potential issues with abrupt app termination on iOS devices, ensuring:
  • All necessary background operations or state-saving mechanisms have sufficient time to complete before suspension.
  • A smoother user experience during app closure.

Code Change

DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
    UIApplication.shared.perform(#selector(NSXPCConnection.suspend))
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
        exit(0)
    }
}

Testing

  • Verified the app termination process on multiple iOS devices to confirm:
  • The app suspends and exits gracefully.
  • No crashes or unexpected behavior during termination.

Impacts

  • This change affects the app termination process in iOS only.
  • No impact on Android or other platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant