darryncampbell / darryncampbell-cordova-plugin-intent

General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
MIT License
86 stars 130 forks source link

with ionic 4+ when app is closed the onIntent is callback is not triggered #121

Closed shamis closed 3 years ago

shamis commented 3 years ago

When the app is running in the background everything is working as expected.

this.webIntent.onIntent().subscribe((intent: { extras: any; }) => {
     console.log('Received Intent: ' + JSON.stringify(intent.extras));
     alert('Received Intent: ' + JSON.stringify(intent.extras));
});

The above code is placed inside platform ready.

Not able to retrieve the extras when the app is closed

darryncampbell commented 3 years ago

Hi, does subscribe register a broadcast receiver? Although this plugin is listed as the implementation for webIntent I didn't actually write any of the code for the webIntent API.

Closing the app will cause Android to unregister any existing dynamic broadcast receivers so this is expected behaviour if I have correctly understood the question.

shamis commented 3 years ago

thanks for the quick response, I had not registered a brodcast receiver just using the package name to startActivity with extras. It works well when the app is in the background. Have not found a way to make it work when the app is closed.

darryncampbell commented 3 years ago

Perhaps the subscription is getting cleared when you close the app? https://github.com/ionic-team/ionic-native/blob/master/src/%40ionic-native/plugins/web-intent/index.ts#L215

shamis commented 3 years ago

I was able to use getIntent when the app was closed. Sorry didnt notice that at first. Thanks for the help.