expo-mail-composer is working properly on my emulator as well as on my actual device, but not on the client's - react-native

This is quite possibly user error, although I cannot really discern how that would be the case here. I have a react native app that has the feature to record and then email videos. It works pretty simply, you press the button to enter the in-app camera, press record to record and stop to stop. Once stopped, the video is saved to the phone, and then two buttons appear; 'cancel' and 'send video'
When send video is pressed, a email composer pops up with some pre-filled information, and you can compose and send an email off of your phone just like you normally would. This works all as expected on my end, but when a client presses the 'send video' button, nothing happens. No error, no email pop up, just nothing.
I've confirmed that she signed up with her email, I've investigated the database and that's true-- so I don't quite understand what could be missing. I tried an emulator for her exact device type and it worked well, so this has to be user error or something with permissions, right?
This is the function that gets run when 'send video' is clicked...
// Sends the Video, triggers the message, opens the modal
function handleSendVid(){
saveVidToLib()
.then(resolved => {
emailVid(resolved)
})
.then(() => {
if (user.role === "GUARDIAN"){
handleSendMessage()
}
})
}
With emailVid() looking like this...
// Emails the now saved video
async function emailVid(video){
MailComposer.composeAsync({
recipients: [therapist.email],
subject: `Video Of Exercise From: ${user.firstName} ${user.lastName}`,
body: "Beta Testing",
attachments: [videoPath]
})
.catch((err) => console.log(err))
.then(() => {
setEmailSent(true)
})
}

Related

openUrl is not working in first attempt for mailto option in emulator in react native

I have tried to open gmail using linking.openUrl - mailto option. I can open gmail in my real device with first attempt.But In emulator its not open in first attempt and if I click same link second time it open gmail.
I couldn't understand what could be the cause.
Sample code:
Linking.canOpenURL(url)
.then(ok => {
if (ok) {
console.log(Linking.openURL(url));
return Linking.openURL(url);
} else {
console.warn("can't open mailto: iOS sim doesn't support it");
}
})
.catch(err => {
console.error(err);
});
Initially checking given url is valid or not. If valid try to open using openUrl concept

Supabase auth.update() email_refresh_token workflow

When I want to let an authenticated user change their email address I use auth.update(), found here https://supabase.com/docs/reference/javascript/auth-update
I'm using just a magic link auth, btw.
Right now my project is set up for only one email confirmation.
Im using vue 3 with vu-router v4
When I run this function
async handleUpdateUser(newEmail: string) {
try {
const { user, error } = await supabase.auth.update({
email: newEmail,
});
if (error) throw error;
} catch (error) {
console.log(error);
}
},
The onAuthStateChange that I log shows as USER_UPDATED, the users.auth table on the server shows the new stuff, and a new_email prop is seen on the user object in the console
My question is how do I make the new_emial into just email.
the link that is sent to the new email is as so
https://correct_info_is_here.supabase.co/auth/v1/verify?token=there_is_a_token_here&type=email_change&redirect_to=http://localhost:3000/
When I click the link, it redirects to a new window just like it does when an initial sign up happens, but other than that nothing changes.
I found this answer,
https://github.com/supabase/supabase/discussions/1763
but I have no idea how to implement that procedure. The only way figured out how to get that token is by an rpc function on the client , but I don't know what to do with that token after I receive it.
Also I might add when I use vue-router, I log the to and from properties of the beforeEach like so
router.beforeEach(async (to, from) => {
console.log("to", to);
console.log("from", from);...
When I load the confirmation link, it doesn't show anything useful like it does when its redirected form the original sign up link.
Any help would greatly be appreciated.
I ran into a similar issue, and in my case, it came down to the "Double confirm email changes" setting in Supabase Studio.
From the Supabase docs for supabase.auth.update:
Email updates will send an email to both the user's current and new email with a confirmation link by default. To toggle this behavior off and only send a single confirmation link to the new email, toggle "Double confirm email changes" under "Authentication" -> "Settings" off.
So what may be happening is that when you request the email change, the user receives two emails: one at the old email address, and one at the new email address. The user must click both links in order for that user's email column to actually be updated.
At least, this was the issue in my case — I hope it helps!

Google Pay dialog back button causes error from loadPaymentData

I have the following code on my website.
My problem is, the user hits "Pay with Google" button to trigger the code below. This shows the Google Pay popup (which is loaded from the loadPaymentData()).
If the user proceeds with the payment, then everything works great.
If the user clicks on the back button within the popup, then this is seen as an error and drops into the catch(function(err)) below. This paymentData or payload is not logged in the console. This is obviously not an error - the user just wants to select a different payment method.
How do I catch if the user has hit the back button within the popup?
paymentsClient.loadPaymentData(paymentDataRequest)
.then(function (paymentData) {
console.log("paymentData", paymentData);
// TODO
}).then(function (payload) {
console.log("payload", payload);
// Send result nonce to server
}).catch(function (err) {
console.log('pay error', err);
});
You can check to see if the payment sheet was cancelled by inspecting err.statusCode === 'CANCELED'.
See documentation: https://developers.google.com/pay/api/web/reference/client#errors_1

React native send an automatic message without opening whatsapp

I'm trying to send a text message to a WhatsApp contact from a react-native apps , i found that i can do it through Linking
Linking.openURL('whatsapp://send?text=hello');
the above code opens whatsapp. I would like to send message without opening whatsapp
you can do it using Share.shareSingle from react-native-share package
const shareOptions = {
title: 'Share via',
message: 'some message',
url: 'some share url',
social: Share.Social.WHATSAPP,
whatsAppNumber: "9199999999", // country code + phone number
filename: 'test' , // only for base64 file in Android
};
Share.shareSingle(shareOptions)
.then((res) => { console.log(res) })
.catch((err) => { err && console.log(err); });
The shareSingle() method allows a user to share a premade message via
a single prechosen social medium. In other words, code specifies both
the message that will be sent and the social medium through which the
message will be sent. The user chooses only to whom the message is
sent. This shared message may contain text, one or more files, or
both.
Checkout - https://react-native-share.github.io/react-native-share/docs/share-single
also i've given working example to share multiple or single images using react-native-share as answer to a question about how to do it. might be useful.
Checkout Here

react native push notification that can be removed after button click

I am using react native v0.45.1.
How can I add to my application notification (no matter if the app is in the background or foreground) that the user can remove only after click an acknowledge button.
I don't want the user to swipe the notification aside without notice it.
how can it be done?
I am not sure https://github.com/wix/react-native-notifications will do what I need.
Edit
I want to have a notification that will act like:
'USB debugging connected
'Touch to disable USB debugging'
The notification can't be removed unless the user actively do something, in my case it will be 'click' on a button
after a lot of digging the solution I implemented was:
setting repeat interval for the notification.
for android:
repeatType: 'time',
repeatTime: timeSpan,
for iOS:
repeatType: 'minute',
when the user click the notification (decided its not the right approached to add actions - buttons - to notification):
PushNotification.configure({
onNotification: (notification) => {
console.log('NOTIFICATION:', notification);
const clicked = notification.userInteraction;
if (clicked) {
if (Platform.OS === 'ios') {
PushNotification.cancelLocalNotifications({ id: notification.data.id });
} else {
PushNotification.cancelLocalNotifications({ id: notification.id });
}
}
},
});
I am aware that this might not be the exact answer to this question. However,
I was looking for a similar solution earlier; how to remove notifications that hasn't been dismissed or opened by a user.
Sometimes the user might open the application / screen, without clicking on the notification. The notification will still be displayed in that case.
Using React Native with Expo, this is the solution I created for removing old notifications created using their Push Notification API.
import * as Notifications from "expo-notifications";
//...
// Remove notifications that exists for this conversation!
useEffect(() => {
Notifications.getPresentedNotificationsAsync().then(res => {
for (let k in res) {
if (
res[k].request.content.data &&
res[k].request.content.data.screen === "Conversations" &&
res[k].request.content.data.conversationId === conversationId
) {
Notifications.dismissNotificationAsync(res[k].request.identifier);
console.log("removed a notification for this conversation");
}
}
});
}, []);
By using the data sent to the Push Notification API, we can determine which notifications should be removed. in this case all notifications containing a conversationId matching the current value from the route are dismissed.