I am trying to use a in app browser in react native using expo and came across the react-native-inappbrowser-reborn package and I tried to use the given code example but always get this error when I alert it:
My code:
async function handleLink(link) {
try {
const url = link;
if (await InAppBrowser.isAvailable()) {
} else Linking.openURL(url);
} catch (error) {
alert(error.message)
}
}
I was wondering if any of you know this error or if there is a working alternative?
This solution from expo works well for me:
import * as WebBrowser from 'expo-web-browser';
const openLink = WebBrowser.openBrowserAsync('https://google.com')
// JSX...
Here are the docs for expo-web-browser
There is a solution which i found few weeks ago
here: How To Add A In-App Browser In React-Native
Related
I am creating an APP using managed expo react native.
And want to implement Toast alerts, react-native provides Toast only for Android not for IOS.
I googled it and found the couple of modules which works on Android and ios but they required some config change in Native code. But as I said I am working on Managed expo app. So, I don't have access for that.
Now let me know how I can implement Toast on this?
Thanks.
As toast is a native feature in android, for ios try snakbar.
import {
ToastAndroid,
Platform
} from "react-native";
import Snackbar from 'react-native-snackbar';
notify = (message) => {
if (Platform.OS != 'android') {
Snackbar.show({
text: message,
duration: Snackbar.LENGTH_SHORT,
});
} else {
ToastAndroid.show(message, ToastAndroid.SHORT);
}
}
** If you are on expo
https://snack.expo.io/#mainak/snackbar
You can use third-party library native-base available for both react-native-cli and expo
[Native-Base] https://docs.nativebase.io/docs/GetStarted.html
[Toast Component] https://docs.nativebase.io/Components.html#toast-def-headref
Expo client app reload/restart after selecting file via DocumentPicker!
Expo SDK Version: 32.0.0
Sample code trying to run, https://snack.expo.io/HkuSxz6Sf
It doesn't provide an error either, it just restarts again!
Please add the code below
async componentDidMount() {
const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
}
I'm trying to open the default phone app from my react native app on a button press. when I searched the web I came to know about the deep linking.
As I'm new to react native I don't have an idea how this works. So can anyone help?
I suggest you to use canOpenUrl() to handle errors and then openUrl('tel:string_of_the_number_to_call'), something like this:
const phoneNumber = '1232456';
Linking.canOpenURL(`tel:${phoneNumber}`)
.then(supported => {
if (!supported) {
// handle the error
} else {
return Linking.openURL(`tel:${phoneNumber}`);
}
})
Hope this helps
I used react-native-image-picker for fetch image form camera and photo library. i follow the steps to and link react-native-image-picker in xcode. I will code also to open imagePicker. but have an error.
Note : I will used 0.46 for react native.
Successfully link in iOS and Android.
My Code :
import { ImagePicker } from 'react-native-image-picker'
And onButton :
handleImagePickUp = () =>{
ImagePicker.launchImageLibrary(options, (response) => {
});
}
Error :
Instead of writing
import { ImagePicker } from 'react-native-image-picker',
you should declare ( In the same place )...
var ImagePicker = require('react-native-image-picker');.
The rest of your code should work, although it's hard to tell since its not provided. Hope this helps, if you dont understand why this must be done let me know.
How do you open a Bitcoin URL in a react native app? I am using React Native Linking to detect if there are any apps on the phone that can open a Bitcoin URL formatted according to BIP21. I have 3 apps installed that should handle it:
1) Coinbase
2) Breadwallet
3) Blockchain.info wallet
But it's not opening. Here's the code:
async _openWallet() {
const coinURL = 'bitcoin:15bMc6sQTiQ5jSqoRX3JzatAbQqJaffqup';
try {
const supported = await Linking.canOpenURL(coinURL);
if (supported) {
Linking.openURL(coinURL);
} else {
console.log('Could not find a compatible wallet on this device.');
}
} catch (error) {
console.log(error);
}
}
supported keeps returning false, which causes "Could not find a compatible wallet..." to execute. The weird thing is if I click on a Bitcoin URL on any random website via the Chrome / Safari browser, I get a popup that asks me if I want to open the URL in one of the above apps. So only URLs on websites are opening, but not URLs from inside react native code.
Any ideas?
Looks like every URI scheme you want to use at runtime must be defined up-front in Info.plist. Found the answer here: React Native: Linking API not discovering Uber app