问题
I've built a Cordova app using the ionic framework. It is build using Peer JS and i need the app to open a state from cold start quickly whenever my peer receives an incoming call, kind of like the phone app opens the incoming call activity when we receive a call.
Currently I'm using ionic push notifications to open the state on click of the notification but that takes too long and loads from the splash screen onwards.
Is there a way to kind of pop open my state containing the receive call code into the foreground quickly
回答1:
For Cordova, the hack that i came up with was,
First, separate the incoming call code into a html page with the required javascript code.
Next, send a notification with a specific payload, then in the onRecieve method in the phonegap push plugin, I check the payload, if it matches the specific payload and if the app is killed, i use an intent to open the main activity which contains the cordova webview, I load the html page here based on the intent.
This makes it appear as if the app "pops open".
来源:https://stackoverflow.com/questions/38252461/pop-up-state-directly-from-coldstart