3

Im currently developing a unity application for both android and ios platforms. I have implemented deep links in the platforms separately using native coding. The problem I have now is the deep linking works perfectly well in both android and ios devices if the app is starting the activity for the first time without it being resumed from the recent history. If the app was minimise and then if a deep link was clicked on the web page the app simply resumes but does not pass the deep link data. I know that this is because I have called the deep linking methods in void Start() method. I tried to get boolean values to check for data from the activity and reload the deep linking part within the void Update() method. But It does not work.

I tried google for hours for a solution. The only option left is to restart the app if its been resumed so that the whole thing will run from the beginning and therefore the deep linking will work in it.

I tried adding 'Application does not run in background' property in info.plist for ios.It worked but I cannot do that for android.

Im using unity 5.3.1f1 on mac and the function void OnApplicationPause void OnApplicationFocus both does not work on it. I manually debugged the code and it does not call the function.

If anyone could let me know if there is a method in unity or android where I can acheive what Im trying it would be a really big help. Thank you

Achala Weerasooriya
  • 215
  • 1
  • 6
  • 18

1 Answers1

1

OnApplicationPause and OnApplicationFocus are the best and recommended ways to do this. OnApplicationPause and OnApplicationFocus are not being called on Android because you probably have Application.runInBackground in your some of your scripts. Remove it if you do have them.

Also, for OnApplicationPause and OnApplicationFocus to to called, you must inherit from MonoBehavior. Your script should look like this:

public class ExampleClass : MonoBehaviour {

    void OnApplicationPause(bool pauseStatus) {

    }

    void OnApplicationFocus(bool focusStatus) {

    }
}

Instead of:

public class ExampleClass : OTHERCLASS{

    void OnApplicationPause(bool pauseStatus) {

    }

    void OnApplicationFocus(bool focusStatus) {

    }
}

OR:

public class ExampleClass {

    void OnApplicationPause(bool pauseStatus) {

    }

    void OnApplicationFocus(bool focusStatus) {

    }
}

If that doesn't solve your problem, then that is likely a bug. Update unity from 5.3.1f1 to 5.3.3 as that is the latest version and may solve your problem.

Programmer
  • 121,791
  • 22
  • 236
  • 328
  • 1
    Also, if you have Virtual Reality enabled, it will overwrite the run in background so you'd need to make sure it is off. – Everts Mar 08 '16 at 10:56