use of com.facebook.react.bridge.ReactMethod in project react-native-track-player by react-native-kit.
the class TrackModule method updateOptions.
@ReactMethod
public void updateOptions(ReadableMap data) {
final Bundle options = Arguments.toBundle(data);
waitForConnection(new Runnable() {
@Override
public void run() {
binder.updateOptions(options);
}
});
}
use of com.facebook.react.bridge.ReactMethod in project react-native-track-player by react-native-kit.
the class TrackModule method add.
@ReactMethod
public void add(ReadableArray tracks, final String insertBeforeId, final Promise callback) {
final ArrayList trackList = Arguments.toList(tracks);
waitForConnection(new Runnable() {
@Override
public void run() {
binder.add(trackList, insertBeforeId, callback);
}
});
}
use of com.facebook.react.bridge.ReactMethod in project react-native-track-player by react-native-kit.
the class TrackModule method setupPlayer.
@ReactMethod
public void setupPlayer(ReadableMap data, final Promise promise) {
final Bundle options = Arguments.toBundle(data);
waitForConnection(new Runnable() {
@Override
public void run() {
binder.setupPlayer(options, promise);
}
});
}
use of com.facebook.react.bridge.ReactMethod in project react-native-iap by dooboolab.
the class RNIapModule method buyItemByType.
@ReactMethod
public void buyItemByType(String type, String sku, Promise promise) {
addPromiseForKey(PROMISE_BUY_ITEM, promise);
BillingFlowParams flowParams = BillingFlowParams.newBuilder().setSku(sku).setType(type).build();
int responseCode = mBillingClient.launchBillingFlow(getCurrentActivity(), flowParams);
Log.d(TAG, "buyItemByType (type: " + type + ", sku: " + sku + ") responseCode: " + responseCode + "(" + getBillingResponseCodeName(responseCode) + ")");
}
use of com.facebook.react.bridge.ReactMethod in project react-native-iap by dooboolab.
the class RNIapModule method getAvailableItemsByType.
@ReactMethod
public void getAvailableItemsByType(String type, final Promise promise) {
if (mService == null) {
promise.reject(E_NOT_PREPARED, "IAP not prepared. Check if Google Play service is available.");
return;
}
Bundle availableItems;
try {
availableItems = mService.getPurchases(3, reactContext.getPackageName(), type, null);
} catch (RemoteException e) {
promise.reject(E_REMOTE_ERROR, e.getMessage());
return;
}
int responseCode = availableItems.getInt("RESPONSE_CODE");
WritableArray items = Arguments.createArray();
ArrayList<String> purchaseDataList = availableItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
if (responseCode == BillingClient.BillingResponse.OK && purchaseDataList != null) {
for (String purchaseJSON : purchaseDataList) {
try {
JSONObject json = new JSONObject(purchaseJSON);
WritableMap item = Arguments.createMap();
item.putString("productId", json.getString("productId"));
item.putString("transactionId", json.getString("orderId"));
item.putString("transactionDate", String.valueOf(json.getLong("purchaseTime")));
item.putString("transactionReceipt", json.getString("purchaseToken"));
item.putString("purchaseToken", json.getString("purchaseToken"));
if (type.equals(BillingClient.SkuType.SUBS)) {
item.putBoolean("autoRenewing", json.getBoolean("autoRenewing"));
}
items.pushMap(item);
} catch (JSONException e) {
e.printStackTrace();
}
}
promise.resolve(items);
} else {
rejectPromiseWithBillingError(promise, responseCode);
}
}
Aggregations