public TwilioPhone(Context context) { if (!Twilio.isInitialized()) { Log.v(LOGTAG, "Calling Initialize on Twilio"); Twilio.initialize(context, this /* Twilio.InitListener */); appContext = context; } else { appContext = context; Log.v(LOGTAG, "Twilio already initialized"); onInitialized(); } }
/* Twilio.InitListener method */ @Override public void onInitialized() { Log.v(LOGTAG, "Twilio SDK is Initialized"); try { Log.v(LOGTAG, "Auth URL: " + appContext.getString(R.string.twilio_auth_url)); String capabilityToken = HttpHelper.httpGet(appContext.getString(R.string.twilio_auth_url)); Log.v( LOGTAG, appContext.getString(R.string.twilio_auth_url) + " Auth Token: " + capabilityToken); device = Twilio.createDevice(capabilityToken, null /* DeviceListener */); Log.v(LOGTAG, "Created Twilio Device"); } catch (Exception e) { Log.e(LOGTAG, "Failed to obtain capability token: " + e.toString()); } }
private void getCapabilityToken(String url, PendingIntent intent) { this.capabilityToken = null; this.device = null; try { this.pendingIntent = intent; this.capabilityToken = HttpHelper.httpGet(url); this.device = Twilio.createDevice(this.capabilityToken, null); Log.d(TAG, this.capabilityToken); if (this.pendingIntent != null) { Log.d(TAG, "setting pending intent"); device.setIncomingIntent(pendingIntent); } else { Log.d(TAG, "incoming call unavailable"); } } catch (Exception e) { Log.e(TAG, "Failed to obtain capability token: " + e.getLocalizedMessage()); } }
public TwilioPhone(Context context, String url, PendingIntent pendingIntent) { this.url = url; this.pendingIntent = pendingIntent; Twilio.initialize(context, this); Log.w(TAG, "Twilio SDK init"); }