Can't quit iOS Unity properly

Hi,

I am currently using UaaL for our Xamarin app. I got everything working instead of a standard quit Unity action.

If I use UnityFramework.QuitApplication. It doesn’t just quit Unity. It closes the entire app.
When I use UnityFramework.UnloadApplication it just unloads Unity and stops working. But also won’t go back to the main page of the iOS app I set up.

I have a button on my app home page that launches Unity. And I have a button that should close Unity again when pressed. And then it should go back to my app home page. But it doesn’t, as I explained above.

Is there a way to do this properly?

Hi!
Here we have a simple project which implements all use cases you mentioned here, you could check it for additional information.
https://github.com/Unity-Technologies/uaal-example

Now to answer your question:
I think you did not defined quitHandler. If this callback is not defined, system uses default quit route which terminates the process. This is how it looks in this sample app:

 // set quit handler to change default behavior of exit app
    [[self ufw] appController].quitHandler = ^(){ NSLog(@"AppController.quitHandler called"); };

I hope it helps :slight_smile:

Hi there,

Thanks a lot for your answer!

I have looked at the UaaL example. But that doesn’t really work in this case as I’m working in Xamarin and not in Xcode anymore. I just change all the code needed in Xcode, then build it and just export the UnityFramework.framework and create an iOS Binding Library in Xamarin to place the .framework in.

And where exactly would I want to place that piece of code?

Hi!

Well, this callback needs to be set before Unity attempts to unload itself so there is no exact place where you have to do it. Usually it is done (like in example) before launching Unity from your native application.

I hope this helps :slight_smile:

Hi,

Thank you for your help!

I got everything working regarding quitting and loading Unity into Xamarin Android and iOS.

But now my next problem is communication. Communication fully works when it comes to going from Xamarin to Unity.

But how can you communicate from Unity to Xamarin? For Android and iOS

I appreciate any help you can provide.

Does that line work with Unload too? I’m facing the same problem with unload