use of com.facebook.react.bridge.ReactMethod in project react-native-fbads by callstack.
the class NativeAdManager method init.
/**
* Initialises native ad manager for a given placement id and ads to request.
* This method is run on the UI thread
*
* @param placementId
* @param adsToRequest
*/
@ReactMethod
public void init(final String placementId, final int adsToRequest) {
final ReactApplicationContext reactContext = this.getReactApplicationContext();
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
final NativeAdsManager adsManager = new NativeAdsManager(reactContext, placementId, adsToRequest);
adsManager.setListener(NativeAdManager.this);
mAdsManagers.put(placementId, adsManager);
adsManager.loadAds();
}
});
}
use of com.facebook.react.bridge.ReactMethod in project react-native-twilio-programmable-voice by hoxfon.
the class TwilioVoiceModule method ignore.
@ReactMethod
public void ignore() {
callAccepted = false;
SoundPoolManager.getInstance(getReactApplicationContext()).stopRinging();
WritableMap params = Arguments.createMap();
if (activeCallInvite != null) {
params.putString("call_sid", activeCallInvite.getCallSid());
params.putString("call_from", activeCallInvite.getFrom());
params.putString("call_to", activeCallInvite.getTo());
params.putString("call_state", activeCallInvite.getState().name());
clearIncomingNotification(activeCallInvite);
}
eventManager.sendEvent(EVENT_CONNECTION_DID_DISCONNECT, params);
}
use of com.facebook.react.bridge.ReactMethod in project react-native-twilio-programmable-voice by hoxfon.
the class TwilioVoiceModule method accept.
@ReactMethod
public void accept() {
callAccepted = true;
SoundPoolManager.getInstance(getReactApplicationContext()).stopRinging();
if (activeCallInvite != null) {
if (activeCallInvite.getState() == CallInvite.State.PENDING) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "accept() activeCallInvite.getState() PENDING");
}
activeCallInvite.accept(getReactApplicationContext(), callListener);
clearIncomingNotification(activeCallInvite);
} else {
// when the user answers a call from a notification before the react-native App
// is completely initialised, and the first event has been skipped
// re-send connectionDidConnect message to JS
WritableMap params = Arguments.createMap();
params.putString("call_sid", activeCallInvite.getCallSid());
params.putString("call_from", activeCallInvite.getFrom());
params.putString("call_to", activeCallInvite.getTo());
params.putString("call_state", activeCallInvite.getState().name());
callNotificationManager.createHangupLocalNotification(getReactApplicationContext(), activeCallInvite.getCallSid(), activeCallInvite.getFrom());
eventManager.sendEvent(EVENT_CONNECTION_DID_CONNECT, params);
}
} else {
eventManager.sendEvent(EVENT_CONNECTION_DID_DISCONNECT, null);
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-twilio-programmable-voice by hoxfon.
the class TwilioVoiceModule method getActiveCall.
@ReactMethod
public void getActiveCall(Promise promise) {
if (activeCall != null) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Active call found state = " + activeCall.getState());
}
WritableMap params = Arguments.createMap();
params.putString("call_sid", activeCall.getSid());
params.putString("call_from", activeCall.getFrom());
params.putString("call_to", activeCall.getTo());
params.putString("call_state", activeCall.getState().name());
promise.resolve(params);
return;
}
if (activeCallInvite != null) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Active call invite found state = " + activeCallInvite.getState());
}
WritableMap params = Arguments.createMap();
params.putString("call_sid", activeCallInvite.getCallSid());
params.putString("call_from", activeCallInvite.getFrom());
params.putString("call_to", activeCallInvite.getTo());
params.putString("call_state", activeCallInvite.getState().name());
promise.resolve(params);
return;
}
promise.resolve(null);
}
use of com.facebook.react.bridge.ReactMethod in project react-native-twilio-programmable-voice by hoxfon.
the class TwilioVoiceModule method connect.
@ReactMethod
public void connect(ReadableMap params) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "connect params: " + params);
}
WritableMap errParams = Arguments.createMap();
if (accessToken == null) {
errParams.putString("err", "Invalid access token");
eventManager.sendEvent(EVENT_DEVICE_NOT_READY, errParams);
return;
}
if (params == null) {
errParams.putString("err", "Invalid parameters");
eventManager.sendEvent(EVENT_CONNECTION_DID_DISCONNECT, errParams);
return;
} else if (!params.hasKey("To")) {
errParams.putString("err", "Invalid To parameter");
eventManager.sendEvent(EVENT_CONNECTION_DID_DISCONNECT, errParams);
return;
}
toNumber = params.getString("To");
if (params.hasKey("ToName")) {
toName = params.getString("ToName");
}
// optional parameter that will be delivered to the server
if (params.hasKey("CallerId")) {
twiMLParams.put("CallerId", params.getString("CallerId"));
}
twiMLParams.put("To", params.getString("To"));
activeCall = Voice.call(getReactApplicationContext(), accessToken, twiMLParams, callListener);
}
Aggregations