Search in sources :

Example 51 with ReactMethod

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);
        }
    });
}
Also used : Bundle(android.os.Bundle) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 52 with ReactMethod

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);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 53 with ReactMethod

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);
        }
    });
}
Also used : Bundle(android.os.Bundle) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 54 with ReactMethod

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) + ")");
}
Also used : BillingFlowParams(com.android.billingclient.api.BillingFlowParams) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 55 with ReactMethod

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);
    }
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) JSONObject(org.json.JSONObject) WritableArray(com.facebook.react.bridge.WritableArray) Bundle(android.os.Bundle) JSONException(org.json.JSONException) RemoteException(android.os.RemoteException) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

ReactMethod (com.facebook.react.bridge.ReactMethod)87 Activity (android.app.Activity)21 WritableMap (com.facebook.react.bridge.WritableMap)17 Intent (android.content.Intent)10 Bundle (android.os.Bundle)10 ReactApplicationContext (com.facebook.react.bridge.ReactApplicationContext)6 WritableArray (com.facebook.react.bridge.WritableArray)5 ArrayList (java.util.ArrayList)5 Camera (android.hardware.Camera)4 InterstitialAd (com.facebook.ads.InterstitialAd)4 ShareContent (com.facebook.share.model.ShareContent)4 LayoutNode (com.reactnativenavigation.options.LayoutNode)4 LoginManager (com.facebook.login.LoginManager)3 ReactActivity (com.facebook.react.ReactActivity)3 LatLng (com.google.android.gms.maps.model.LatLng)3 NotificationManager (android.app.NotificationManager)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 RemoteException (android.os.RemoteException)2 NativeAdsManager (com.facebook.ads.NativeAdsManager)2 JSApplicationIllegalArgumentException (com.facebook.react.bridge.JSApplicationIllegalArgumentException)2