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

Fixed Unity not receiving lifecycle events from iOS #704

Merged
merged 1 commit into from
Nov 14, 2022

Conversation

jakeobrien
Copy link
Contributor

Description

There are some casting bugs preventing iOS lifecycle events (didBecomeActive, wilEnterForeground, etc) from reaching unity. This causes two issues:

  • OnApplicationPaused() callbacks don't fire in unity
  • When the app is backgrounded, Unity does not pause, causing high cpu/battery usage while backgrounded

This patch fixes these casting bugs.

Specifically:

  • line 173 fixes an attempted cast of the .appController() method itself to the object the method returns. Since the method isn't actually called, nothing is returned and the casting fails.
  • lines 202-208 fix an attempted cast of NSNotification.Name (an enum) to a String. This cast fails and so the code path wiring up the observer is skipped.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@jakeobrien jakeobrien changed the title Fixed unity not receiving lifecycle events from iOS Fixed Unity not receiving lifecycle events from iOS Oct 27, 2022
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.

3 participants