Here’s the case, we have a native Android app that’s connected to a server and each user has a session id, this app will open a unity app at some point but we need to pass the user’s session id from the native app to the unity app. Is this possible?

We don’t want make the user re login in the unity app.

We will need to do the same for iOS in the future too

From Eclipse/Android Studio inside Java code, use the UnityPlayer.UnitySendMessage method as described in the notes below the code of Example 3:

…and detailed in the iOS implementation (see Calling C# / JavaScript back from native code):

How are you going to launch the Unity game from the other app ?

On Android, when launching a new Intent, you can supply extra data (extras) to it, that can be picked up from the launched app.

A high level process of how that would work out:

  1. The native android app launches the Unity game using an Intent, and places the session id as an extra (intent.putExtra)
  2. A custom Activity is used for the Unity game, grabbing the sent extras in its onCreate method and storing it.
  3. From Unity (C#) code, access the stored session id (using AndroidJavaObject and the likes) to get the passed value.

Let me know if this is sufficient or whether code samples would be needed.