expo-share getting error while sharing hyperlink (deeplink) - react-native

i am trying to share link using expo-sharing, it works sharing file and hyperlink but gives me error on sharing like with custom "scheme", that is link like deeplink eg:
"myapp://detail/cjhqNmpzbDB5aWE/car"
<TouchableOpacity
onPress={async () => {
const isSharable = await Sharing.isAvailableAsync();
if (isSharable) {
await Sharing.shareAsync(
"ekaa://detail/cjhqNmpzbDB5aWExOXZscg==/Luxurious Wooden"
);
}
}}
>
<Text>Share</Text>
</TouchableOpacity>
getting error on line:
await Sharing.shareAsync(
"ekaa://detail/cjhqNmpzbDB5aWExOXZscg==/Luxurious Wooden"
);
error:
Possible Unhandled Promise Rejection (id: 11):
Error: You don't have access to provided file.
promiseMethodWrapper#http://192.168.1.78:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:2485:45
#http://192.168.1.78:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:93192:46
#http://192.168.1.78:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:222066:51
generatorResume#[native code]

Related

firebase TypeError: null is not an object (evaluating '_n7.indexOf') React Native

I am trying to set up a listener for my user document:
const userListener = onSnapshot(doc(db, "users", uid), (doc) => {
setUser(doc.data());
console.log(doc.data());
});
useEffect(() => {
userListener();
setLoading(false);
}, []);
But I keep getting this error:
TypeError: null is not an object (evaluating '_n7.indexOf')
The error redirects me to the index.rn.js file in the firestore folder from my node_modules:
null is not an object (evaluating '_n7.indexOf') file
I have also tried using collection, instead of doc and still get the same error.
Does anyone have an idea where this error is coming from?

Expo-Auth session is not working properly

While implementing google login using the expo-auth-session package , I am getting some error that i don't have any idea about, It has been more than one day since i am stuck in this problem i cannot find a reliable source to use for implementing google login in my expo application. Is there any other way i can implement it in the react native expo application.
The error i am getting are :
WARN Linking requires a build-time setting `scheme` in the project's Expo config (app.config.js or app.json) for production apps, if it's left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. [Learn more][1]:
WARN EventEmitter.removeListener('url', ...): Method has been deprecated. Please instead use `remove()` on the subscription returned by `EventEmitter.addListener`.
WARN Possible Unhandled Promise Rejection (id: 2):
Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.
What should i do ??
The link to the documentation that i followed is :-
And this is what i used from the documentation.
import * as Google from "expo-auth-session/providers/google";
import * as WebBrowser from "expo-web-browser";
WebBrowser.maybeCompleteAuthSession();
const [request, response, promptAsync] = Google.useAuthRequest({
expoClientId: expoClientId,
});
const login = ()=>{
useEffect(() => {
if (response?.type === "success") {
const { authentication } = response;
console.log(authentication);
}
}, [response]);
return (
<Pressable style={styles.btn} onPress={promptAsync}>
<Image
source={require("../../../assets/g1.png")}
style={styles.img}
/>
<Text style={styles.text}>Sign in with Google</Text>
</Pressable>
)
}
thank you any help would be appriciated.
In your app.json add following
"scheme":"com.yourpackage.yourapp"
this value must be same as your android.package and ios.bundleIdentifier

How to share a qr code image using expo-sharing?

I generate a qrcode using 'react-native-qrcode-svg' <QRCode size={100} value={deepLink} getRef={(c) => (svg = c)} />and I want to share the QR image using expo sharing, I tried this way but didn't work, gives me this error when sharing [Unhandled promise rejection: Error: Only local file URLs are supported (expected scheme to be 'file', got 'data'.]
I have a share button that calls this function
var svg: any;
let openShareDialogAsync = async () => {
if (!(await Sharing.isAvailableAsync())) {
alert(`Uh oh, sharing isn't available on your platform`);
return;
}
svg.toDataURL((link: any) => {
console.log(link);//the base64 string
Sharing.shareAsync('data:image/png;base64,' + link);
});
};
I'll appreciate it If someone can help me with it. I tried using react-native-share but didn't work with expo, I believe I need to eject the project in order to work with it.

mDNS on react-native Request failed with status code 500

I am currently working on an IoT project which requires service discovery (I am in the Android side). I decided to use react-native-zeroconf and I encountered a problem.
There is a warning Error: Request failed with status code 500 once I called .scan() method.
I have already added permission into the AndroidManifest file. Thank you in advance.
Edit: remove async from function
export function scanmDNS() {
const zeroconf = new Zeroconf();
zeroconf.scan();
const res = zeroconf.getServices();
console.log({ res });
zeroconf.stop();
}
Object {
"res": Object {},
}
Possible Unhandled Promise Rejection (id: 0):
Error: Request failed with status code 500
createError#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:224752:26
settle#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:224742:25
onloadend#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:224619:15
dispatchEvent#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:33843:31
setReadyState#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:32985:29
__didCompleteResponse#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:32783:29
emit#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:4940:42
__callFunction#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:5979:36
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:5707:31
__guard#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:5933:15
callFunctionReturnFlushedQueue#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:5706:21
callFunctionReturnFlushedQueue#[native code]
Possible Unhandled Promise Rejection (id: 1):
There are two ways to handle Promises, since you're using async/await syntax your response should use the await keyword also you are wrapping your response in an object which you shouldn't (without assigning it to a property).
const res = await zeroconf.getServices();
console.log(res)
The other way would be
zeroconf.getServices()
.then((res) => {
console.log(res) //do whatever you want to do with your response here
})
.catch((err) => {
console.log(err) //handle errors here.
}
Not sure if this will solve your problem but hope it leads you to your solution :)

React Native: Network error when using axios on local server

I'm new to react-native, I want to fetch some data from my local laravel server, but I fire the mobx action I get the following errors:
Network Error
[Unhandled promise rejection: Error: Network Error]
This is my mobx action (I'm using flow, similar to async/await), I get 'fire' log but after that I get the error above:
listProducts = flow( function*(payload)
{
console.log('fire');
try
{
let response = yield axios.get('http://192.168.1.39:8000/api/products', { params: payload });
this.posts = response.data;
this.pagination = response.data.pagination;
console.log(response);
//return response;
}
catch (error)
{
console.error(error);
throw error;
}
});
As you can see I'm using my local IP instead of localhost, I'm also testing my app on my android device using EXPO connected to the same network as my dev laptop.
Ciao, I can't see errors on your code. Try to follow this guide to handle Unhandled promise rejection. Could help you to find a clue.
In brief the guide suggest to use axios interceptors:
axios.interceptors.response.use(
response => response,
error => {}
)