I am making calling app using twilio sdk i have integrated all stuff and it is in wokring condition. But the problem is when my android app remains in the background for long time then app didn't receive incoming call request , pending intent not invoked by Twilio Here is the code:
if (!Twilio.isInitialized()) {
/*
* Needed for setting/abandoning audio focus during call
*/
Twilio.initialize(context, new Twilio.InitListener() {
/*
* Now that the SDK is initialized we can register using a Capability Token.
* A Capability Token is a JSON Web Token (JWT) that specifies how an associated Device
* can interact with Twilio services.
*/
@Override
public void onInitialized() {
isInitialized = true;
Twilio.setLogLevel(Log.VERBOSE);
/*
* Retrieve the Capability Token from your own web server
*/
retrieveCapabilityToken();
}
@Override
public void onError(Exception e) {
isInitialized = false;
Logging.e(TAG, e.toString());
notifyOnStopListening(null,-1,context.getString(R.string.error_message_not_connecting));
}
});
} else {
retrieveCapabilityToken();
}
}
private void retrieveCapabilityToken() {
// in the success of api response
if (clientDevice == null) {
clientDevice = Twilio.createDevice(capabilityToken,deviceListener);
}
if(clientDevice != null) {
Intent intent = new Intent(context, ReceiveCallActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
clientDevice.setIncomingIntent(pendingIntent);
isIntentAdded = true;
Logging.e(TAG,"in addPendingIntent intent added");
}
}
Any suggestion , help would be appreciated.