public ChromeCustomTabsModule(ReactApplicationContext reactContext, Activity activity) { super(reactContext); mActivity = activity; mContext = reactContext; String packageName = CustomTabsHelper.getPackageNameToUse(mActivity); mCustomTabActivityHelper = new CustomTabActivityHelper(); mCustomTabActivityHelper.setConnectionCallback(this); mCustomTabActivityHelper.bindCustomTabsService(mActivity, reactContext.getApplicationContext()); }
@ReactMethod public void mayLaunchUrl(String url) { Boolean didWarm = mCustomTabActivityHelper.mayLaunchUrl(Uri.parse(url), null, null); if (didWarm) { this.sendEvent("didWarmUrl"); } else { this.sendEvent("didNotWarmUrl"); } }
@ReactMethod public void launchCustomTab(String url) { CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder(mCustomTabActivityHelper.getSession()).build(); mCustomTabActivityHelper.openCustomTab(mActivity, customTabsIntent, Uri.parse(url), null); }