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

Using startApp.getExtras() to retrieve vars if external app is already open in background? #149

Open
rolinger opened this issue Sep 5, 2020 · 1 comment
Labels

Comments

@rolinger
Copy link

rolinger commented Sep 5, 2020

Using primary app to call/open a secondary app. In secondary app, retrieving params/vars with startApp.getExtras() works fine if the secondary app is not running. But how can I retrieve vars passed from the primary app if the secondary app is already running in the background?

$ionicPlatform.ready(function() {

    function onResume() {
      startApp.getExtras(function (inObj) {
        console.log("startApp getExtras called") ;
        console.log(inObj) ;
      }, function (fail) { /* fail */
          console.log(fail);
      });
    }
    onResume() ; 
   // calls function when app is ready
   // works fine if app is not running in the background
   // vars/params are successfully retrieved

    document.addEventListener("resume", onResume, false);  
    // listens for resuming app sitting in background
    // this triggers if app is in background and brought to the foregroun
    // it calls the onResume function, BUT, onResume doesn't retrieve vars/params
}

In the secondary app, the addEventListener works, it fires the onResume function when the app is brought to the foreground, however, it doesn't get the vars/params passed into it from the primary app.

On app resume, the console.log(inObj) does output the following object, but none of the vars passed in from Primary app:
{profile: "0" }

How can this be resolved?

@rolinger rolinger changed the title Using startApp.getExtras() to retrieve vars if external app is already open? Using startApp.getExtras() to retrieve vars if external app is already open in background? Sep 5, 2020
@zzyyu
Copy link

zzyyu commented Oct 13, 2023

You can add code in MainActivity.java

    @Override
    public void onNewIntent(Intent intent)
    {
        super.onNewIntent(intent);
        setIntent(intent);
    }

This allows the Android app to refresh the intent and receive new data

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

No branches or pull requests

3 participants