Android pending intent not invoked in twilio incoming call

我们两清 提交于 2019-12-11 04:48:13

问题


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.

来源:https://stackoverflow.com/questions/43410494/android-pending-intent-not-invoked-in-twilio-incoming-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!