Change sound in expo.sendPushNotificationsAsync - react-native

I want to play some other sound when hitting any notification in my expo app from node server.I can't find any other sound than 'default'.Is there any other option I can use to play some other sound other than the default one on notifications in expo.My nodeJS code is below:
const receipts = expo.sendPushNotificationsAsync([
{
to: userObj.pushToken,
sound: 'default',
body: notification,
data: { withSome: notification },
priority: 'high',
},
]);

I looked up in the Message Format section of the docs and found this :
A sound to play when the recipient receives this notification. Specify
"default" to play the device's default notification sound, or omit this
field to play no sound.
Note that on apps that target Android 8.0+ (if using `expo build`, built
in June 2018 or later), this setting will have no effect on Android.
Instead, use `channelId` and a channel with the desired setting.
sound?: 'default' | null,
Looks like it is not possible to change sound through app.

Related

Twilio remote video is dark on iOS Safari

I am using Twilio Video for creating a video/chat application, and the remote video tracks are displayed dark on Safari IOS (Using Safari Technology Preview) as shown in the picture below. (One way video)
I was thinking the issue is with the Browsers Autoplay Policy, but i think this should not be the case, since the audio track is played, while the video track remains dark.
Also, i make sure that the user presses a "Join Call" button, to ensure user interaction, which allows the rendering of a component which runs this React useEffect.
The codec of the video is H264, to ensure all Safari users can join the Room (Group Room)
useEffect(() => {
const canConnectToRoom = !room && !isConnectingToRoom && token && roomName
if (canConnectToRoom) {
connectToRoom(token, {
video: false,
name: roomName,
})
}
}, [room, isConnectingToRoom, token, roomName, connectToRoom])
Any help would be appreciated, thanks.
UPDATE 1:
TO RECEIVE THE REMOTE VIDEO STREAM
1. Render a RemoteParticipant component:
The collapsed code is for rendering a fallback UI when the remote camera is disabled (This gets shown when the remote camera is disabled, but when the remote camera is enabled just a dark screen)
2. Extract the participant publications
3. Render the publication tracks as:
4. Render the Video Track
5. Warnings in Safari Console
The warnings in the console are printed out until i allow microphone access. I tried joining the room after allowing microphone access, we eliminate console warnings that way, but remote video is still dark.

Cannot register device with TalkJs for push notifications

I am working on a React Native app that uses TalkJS. We want users to get a push notification for every message they receive. The messages are going through but we aren't getting notifications. We have uploaded our .p12 to the TalkJS dashboard and followed the docs for setting up a React Native project. Below is the relevant code we're injecting to the TalkUI loadScript. We followed https://talkjs.com/docs/Features/Notifications/Mobile_Push_Notifications.html
const res = await window.talkSession.registerDevice({ platform: "ios", pushRegistrationId: "${deviceToken}"});
alert("registering deviceToken ${deviceToken} response: " + res)
We are getting the alert with the correct deviceToken but this method does not return anything. We tried .then and an error first callback but nothing is coming back from this method.
Edit: this method is not designed to return anything, so the response is expected to be empty.
The Promise was designed to not return anything as Kapobajza mentioned.
From their support chat: "We have an issue regarding push notifications on iOS when using React Native."
Edit: this issue has been resolved. In addition to work that needed to be done by the TalkJS team, push notifications require a user to have a 'role', as is very loosely implied in the Overview for Push Notifications

Can I modify expo push notification title/body before showing the notification?

I'm using expo notification service.
I would like to send keys from backend, e.g.
{
title: "TITLE_KEY",
body: "BODY_KEY"
}
then translate it when it comes on the mobile side (based on the key), before showing it, so user would not see the key on notification, just the translated text...
So the question is how could I modify notification before showing it to the user?

Group notifications with Expo

I have a react native messaging app done with Expo. I got notifications to work, but the problem is that each message is a separate notification.
I would like to group notifications sent by the same person. Currently, I have:
[Notification]
John - Hey, how are you?
[Notification]
John - Long time no see!
and I would like them to merge as a single one when the second message is received, like this:
[Notification]
John |
Hey, how are you?
Long time to see!
I might be missing something because I cannot find anyone else wondering about such a common functionality.
The code I use to send notifications from my backend (python):
headers = {
'Accept': 'application/json',
'Accept-encoding': 'gzip, deflate',
'Content-Type': 'application/json',
}
session.post(
"https://exp.host/--/api/v2/push/send",
json = {
"to": expo_token,
"title": username,
"body": message_content,
},
headers=headers
)
In iOS you should use apns-collapse-id
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns
An identifier you use to coalesce multiple notifications into a single
notification for the user. Typically, each notification request causes
a new notification to be displayed on the user’s device. When sending
the same notification more than once, use the same value in this
header to coalesce the requests. The value of this key must not exceed
64 bytes.
Update
For using collapse feature, you can use for Notifications other service. Which supports collapse and react native - for example
https://documentation.onesignal.com/docs/how-notifications-work#section-notification-collapsing
It seems like you can not control how notifications group in Expo app now, but I noticed that on IOS they are being grouped together automatically, while on Android you need to set notification.androidMode to collapse.
Take a look at current documentation: https://docs.expo.dev/versions/latest/config/app/#androidmode
app.json
Path: notification.androidMode
Type: enum
Show each push notification individually (default) or collapse into one (collapse).
All your messages will still be separate notifications, but at least they will collapse into one (stack).
That will only work in standalone app, nor in Expo Go.

react-native-video: How to manually select video quality

I am building an app for video streaming using HLS from s3.
I want to support the functionality to select Video Quality.
Still unable to find how to select the desired quality.
Can any one please help me in this issue.
If some one knows some react-native api or some other solution, please help.
Thanks
it is possible to select a video quality manually according to the react-native-video documentation use the selectedVideoTrack Prop
see https://github.com/react-native-community/react-native-video#selectedvideotrack
example
selectedVideoTrack={{
type: "resolution",
value: 1080
}}
add these lines in react-native.config.js
module.exports = {
dependencies: {
'react-native-video': {
platforms: {
android: {
sourceDir: '../node_modules/react-native-video/android-exoplayer',
},
},
},
},
assets:['./src/assets/fonts/'],
};
remove assets:['./src/assets/fonts/'], if you don't have fonts directory.
Then in Video component select video track like this
selectedVideoTrack={{
type: "resolution",
value: 1080
}}
This solution tested with only Android devices.
Original answer: https://stackoverflow.com/a/71148981/4291272
If you have multiple quality renditions in your HLS video, you could use hls.js for the playback component. Normally this will just switch playback for you, but you can control this manually with the Quality Switch API.
I.e. you would get the available qualities using hls.levels and then iterate through them. Then set hls.currentLevel tot he desired quality.