implementation 'androidx.browser:browser:<version>'
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
BcPaySampleTheme {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
val context = LocalContext.current
Button(onClick = ::launchBcPay) {
Text("Launch Blockchain.com Pay")
}
}
}
}
}
private fun launchBcPay() {
val widgetUrl = "https://www.blockchain.com/pay/widget?apiKey=[your-api-key]"
val intent = CustomTabsIntent.Builder().build()
intent.launchUrl(
this@MainActivity,
Uri.parse(widgetUrl)
)
}
}
implementation 'androidx.browser:browser:<version>'
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<Button>(R.id.btnLaunchBCPay)
.setOnClickListener {
launchBcPay()
}
}
private fun launchBcPay() {
val widgetUrl = "https://www.blockchain.com/pay/widget?apiKey=[your-api-key]"
val intent = CustomTabsIntent.Builder().build()
intent.launchUrl(
this@MainActivity,
Uri.parse(widgetUrl)
)
}
}
import React from 'react';
import { TouchableOpacity, Text } from 'react-native';
import { CustomTabs } from 'react-native-custom-tabs';
const App = () => {
const openCustomTab = async () => {
try {
await CustomTabs.openURL('https://www.blockchain.com/pay/widget?apiKey=[your-api-key]', {
toolbarColor: '#FF5733', // Customize the toolbar color
enableUrlBarHiding: true, // Enable hiding of URL bar on scroll
showPageTitle: true, // Show the webpage title in the toolbar
enableDefaultShare: true, // Enable the default share action
animations: {
startEnter: 'slide_up', // Set enter animation (slide_up, slide_down, slide_in_left, slide_in_right)
startExit: 'slide_down', // Set exit animation (slide_up, slide_down, slide_out_left, slide_out_right)
endEnter: 'slide_up', // Set enter animation for closing (slide_up, slide_down, slide_in_left, slide_in_right)
endExit: 'slide_down', // Set exit animation for closing (slide_up, slide_down, slide_out_left, slide_out_right)
},
});
} catch (error) {
console.error('Error opening Custom Tab: ', error);
}
};
return (
<TouchableOpacity onPress={openCustomTab} style={{ alignItems: 'center', marginTop: 50 }}>
<Text style={{ fontSize: 18 }}>Open Custom Tab</Text>
</TouchableOpacity>
);
};
export default App;
Customizing a Chrome Custom Tab (Android View System and Jetpack Compose)
val intent = CustomTabsIntent.Builder()
.setDefaultColorSchemeParams(
CustomTabColorSchemeParams.Builder()
.setToolbarColor(colorPrimaryLight)
.build()
)
.setColorSchemeParams(
CustomTabsIntent.COLOR_SCHEME_DARK, CustomTabColorSchemeParams.Builder()
.setToolbarColor(colorPrimaryDark)
.build()
)
.build()
val intent = CustomTabsIntent.Builder()
...
.setStartAnimations(this, R.anim.slide_in_right, R.anim.slide_out_left)
.setExitAnimations(this, R.anim.slide_in_left, R.anim.slide_out_right)
.build()
Using these in-app chrome tabs can elevate your app's performance and user experience.