Is there any way to intercept reloading event for Android? - react-native

When I am running my application on Android device (virtual device) It connects using WebSocket. It's normal flow and there is no question here. When I am using the virtual device for developing I use "Reload" all the time (sure). Can I intercept the reloading process for disconnecting the WS connect? If I do not it manually that my backend won't get relevant event.

You can try to emit the disconnect message in the componentWillUnmount() function. It is bad to use it in a normal app flow (in a back button for example) as it is normally an async function and it is not a good approach to call async functions in the componentWillUnmount(), but in cases that you will only handle the "quit" (reload in your case) I think that this solution can help.

Related

API calls are blocking other touchables in the screen - React Native

When a API call is happening, Im not able to click any touchables in the screen. They wont respond until the API call is done. Is there any solution for this?
I tried with many react native components like TouchableOpacity, TouchableHighlight, Pressable but the main issue is onPress itself is not trigger when the API call is in process.
You must use async/await or .then while making api calls. if you are not using these your app will stop working until api call completes or promise resolves.
Can you open the dev tool and set show perf monitor on and check the JS FPS?
Async functions usually don't block touchables while they are running in the background. Regardless if you use async/await or .then.
According to what you have provided, it seems that your JS thread is freezing which means there are many processes running in the background.
Can you please share a snippet of the code you are running?

Expo/React Native : A Continuous Alarm or Sound Notification (like receiving a call ) triggered by remote server

I am using Expo to build an app that will pop up a notification with custom sound and vibration when triggered remotely. The alarm/vibration would play until its dismissed by the user or it times out (say after 1-2 mins) .
Example use case would be when a partner needs my immediate help with baby, they can press a button the app and that would send signal to backend server which would then trigger the notification with alarm on the app at the other end. When the notification is dismissed, an acknowledgement message is sent with Yes or No type message. If the notification times out, then another message is sent like "no response".
Key point to note is that when the app is fully closed, the notification should still be able to pop up.
From my limited understanding , expo notification or push notifications in general cannot achieve this as they don't allow us to create notifications that directly open the app. Even a solution which works like phone or video calling apps (which open when someone calls you ) could work.
Any help would be much appreciated.
Many Thanks!
I looked up expo push notifications but they are limited in terms of customising the notifications.

Twilio Disconnection event not firing on IOS

I'm creating mobile app based on Twilio and Cordova (https://github.com/jefflinwood/twilio_client_phonegap), it works well, but I seem to have a problem with connection events.
The problem is ConnectionDelegate callback connectionDidDisconnect doesnt seem to be fired in some situations. For example:
User 1 is calling from browser
User 2 anwsers on iPhone/Android/Browser
They talk
User 1 hangs up in browser
User 2 will get disconnection event on every other device than iPhone. On iPhone callback connectionDidDisconnect is not called at all.
Another situation:
User 1 is calling from browser
User 2 anwsers on iPhone/Android/Browser
They talk
User 2 hangs up
User 2 will get disconnection event on every other device than iPhone. On iPhone callback connectionDidDisconnect is not called at all.
Could you tell me where I'm making mistake?
UPDATE:
When user anwsered incoming call on iPhone and caller hangs up I get [ERROR TCMetricsPublisher] Failed to push call stats, status code: 403 error.
When user anwsered incoming call on iPhone and he hangs up, nothing happends.
From others experience using the same plugin, it seems you can solve the issue by using the status callback that Twilio handles when the call ends. Modify the call from parameters and set the status to "completed" for this call.
Doing this should allow the call to disconnect properly on iOS.
Please let me know if this helps at all.

how to connect disconnect the camera device using getUserMedia and webRTC

I am creating an audio/video and chat application using webRTC and Node.js. I need to mute and unmute the camera device.
Presently, I am able to disconnect and the other party is not able to see me, but the problem I see is that it doesn't disconnect the camera. It still remains active and connected as I see the camera flash still on.
I need help how to disconnect when muted and connect it back when unmuted. I want the same feature as we see in skype video call.
It varies a bit between Firefox and Chrome. These steps, in this order, work for me.
1) Set the src property on your video element to empty string ''.
2) Make sure the stop method exists before calling it as a function. Firefox doesn't have it, and if you try to run it, your code will throw an error.
if (localStream && localStream.stop) {
localStream.stop();
}
3) After you call cameraStream.stop() (or not), set localStream = null. (Maybe not actually necessary, but it couldn't hurt to let the object get garbage-collected. And when the user asks to start the camera up again, you can check against the variable to see if you need to clean up after the previous stream before starting a new one.)
When you are getting your media, in your success callback function you have to keep your localstream in a variable. Then, when you want to stop your stream, you can do localstream.stop();
To start again, you can repeat to call your getUserMedia() method again.

get url event on app open in objective c (Mac OSX)

I'm writing a very lightweight app for OSX 10.6+ which will respond to a user clicking on a URL, pass that URL to another application via TCP and then exit.
So far it has registered fine to launch when a user clicks the custom url scheme. However the event seems to get lost if the app is not already running. So the users clicks the link, the app loads, but nothing happens. Once the app is running, if the user clicks the link then it grabs the event and processes it as normal.
What do I need to do to catch that initial event that causes the app to open in the first place?
Currently I'm creating the NSAppleEventManager in the applicationDidFinishLaunching method, and this works for all events created AFTER the initial load, just not for the one that actually opened the app itself.
Any advice would be brilliant!
Thanks!
You should be creating your AppleEvent handlers in -applicationWillFinishLaunching: instead.
The idea is to have your handlers ready to go before your application begins processing AppleEvents.