Best way to handle multiple socket.io connections with mobile safari? - iphone

I have created a node.js/socket.io/express site that has 2 screens, a lobby screen and a game screen. User's login and arrive in the lobby, where they can sit down and when someone sits down across from them a second browser window opens with the game in it. So two browser windows are open at once.
Things seem to work fine in desktop browsers, and the users stay connected to the lobby and the game screen, finish playing a game, and successfully return to the lobby afterwards.
However, in mobile safari (iPad, iPhone), I'm feeling pretty stuck! As soon as the game screen opens, and the lobby screen no longer has focus, it seems that the socket connection to the lobby instantly closes. Is there a way to prevent that from happening? Can I just set a really big timeout interval?Or is this just the way socket.io works with mobile safari? And if it's just the way it works, is there a best practice to achieve the equivalent of what I want to achieve instead?
Thanks!

Related

Why can't I get a MediaStream from back camera when front camera is in use on Android Chrome?

Consider this:
What I'm trying to do here is to get a MediaStream for environment facing camera (back) when another MediaStream for user facing camera (front) is active.
This is happening on Android Chrome 94 and Android MS Edge 93, therefore I think it's probably a webview related issue, not sure. I tested this on an Xiaomi phone and on 2 different Samsung tablets.
If I stop the track from the front stream before creating the new stream, I don't have any issue at all.
It's really strange, because same piece of code works perfectly on PC (Windows) Chrome (not tried macOS or iOS at the moment).
Thing is that stopping the first track before creating the second stream will give the user a pretty bad experience (with blank screen for a while), which I'd like to avoid.
Also there could be some use cases (e.g. PiP) in which using both cameras at once could be necessary... I can't see why this isn't/shouldn't be working.
Do you guys have any suggestion?
Thanks

Oculus Go: How to keep awake while still in app

I'm working on an Oculus Go app, using Unity, where the user is literally expected to sleep while using the app and with the headset still on their head. I seem to be running into the problem where the Oculus Go goes into power-save mode because of inactivity. Presumably, the user isn't moving enough when they are in a deep sleep.
Although I've included instructions for the user on how to disable sleep as a device-wide setting, this is far from ideal. iOS has idleTimerDisabled (Keep iPhone from sleeping) which is a simple one-line stay-awake type of command. I'm looking for the Oculus Go equivalent of iOS's idleTimerDisabled
Does anyone have any hints on how to keep the Oculus Go from turning off?
Just to be clear, this stay-awake behavior should only happen while the user is wearing the headset and using the this app, and only this app. If the user takes off the headset, normal turn-off behavior should be immediately restored.
Thanks in advance,
JJ
Include
Screen.sleepTimeout = SleepTimeout.NeverSleep;
in your MonoBehaviour script if you just want keep the device awake while app is running and helmet is worn.
https://docs.unity3d.com/ScriptReference/Screen-sleepTimeout.html
As of May 2019, it is not possible to keep the Oculus Go awake. Oculus wrote to me
Unfortunately, this doesn't look to be functionality (disabling sleep when there is no movement) that is available at this time.

GKTurnBasedMatch push notifications are very inconsistent

I'm testing a turn based game between two devices. As far as I understand, sending a turn with [GKTurnBasedMatch endTurnWithNextParticipants:], for example, should automatically push a game center notification to the opponent. Sometimes, this works just as expected: the turn is sent and right away a banner notification shows up on the other device. All is well.
What is baffling me is that other times, even though the turn itself is sent properly (I can tell because when the opponent refreshes the matches, the match is up-to-date), there's no push notification coming in.
Are there any holes in my understanding here? If I'm understanding correctly, the inconsistent notifications shouldn't have anything to do with my code, because the issue here isn't how I handle notifications, it's that there is no notification at all. In other words, [handleTurnEventForMatch:] (aGKTurnBasedEventHandlerDelegate method) doesn't have anything to do with it (I don't think) because if no notification is being received, it's never going to be called anyway.
So, I'm just wondering if anyone has had any experience with this. Is it possible that this is due to something in my code? Or, is it possible that the Game Center sandbox is responsible for the inconsistencies, and there's nothing I can do about it?
Any thoughts or ideas would be much appreciated.
It is an issue with GameCenter's sandbox mode. In order for your device to enter sandbox mode you have to open/run your app and authenticate game center. If you say, open a different (published) game after your game is open it will leave sandbox mode and and go back to regular game center mode.
Even if your game is running in the background, as long as it is the last game-center enabled game opened you should get the push notifications as normal. But if you open the game, and then kill the process, you will no longer be in sandbox mode and will not receive the push notifications.
For those who are experiencing similar problems: this turned out to be a Game Center sandbox problem. It had nothing to do with my code, and things were fine in the App Store release. So, read through the comments here and make sure there aren't other things factoring into whatever issues you're having...but know that it's possible that you're simply experiencing some Game Center sandbox issues that are out of your control!
I am also facing the same problem. My game stops receiving turn events and turn notifications from Game Center, I finished my game and was testing, but this week, the problem started to happen. It was working like a charm but suddenly instances started not to receiving turn events for a couple of days.
I am using the iOS7 SDK and targeting iOS7 (turn event handling is different than prior iOS versions, I will need exchanges in upcoming game features, that's why I am using iOS7).
Then I made a test app to check if it was same with iOS6 and prior SDKs, but no help, it was same. So don't waste your time to upgrade your code to iOS7 hoping it would work, the problem is there. I also tried many things, like resetting devices and settings, using new users, etc.
I also tried it with Ray Wenderlich's Turn-Based Gaming with iOS 5 tutorial, by downloading source code, and it doesn't work neither.
The thing is, usually when I launch the game, game receives turn events, but after a few turns, it just stops, and when it stops receiving, stops like forever. If I reload the match, I can get the updated match and it's data is also updated, so I can make the turn. It means match is updated on Game Center. So, either Game Center is not pushing the data to users (possibly this is happening because user cannot receive notifications from Game Center when the game is in background), or the GameKit is not firing the event to the handler.
I don't know why it is happening, or why it started to happen, but I can't release my game like this, hoping that it would work out of sandbox. I will be trying a couple of more things (like maybe trying turn reminders of iOS7, to see if they push it to the user), then I will ask to Apple's support team. One other thing i am planning to do is, putting my test app to App Store and see it if works out of sandbox.
Hopefully it is a sandbox problem.

Application which work in background only iPhone

I have requirement for an application which work in background only.
When first time application install on device then after installation that will be go to background. And after two minutes a view will popup on screen.
Now problem is that after installation how to redirect application into background?
i get answer for this that if we want to send our app into background then we have to open another app like as safari. so i get this solution.
Now problem is that how show a view after two minutes from background. I have to create as a demo not for app store. So if anyone have any solution then suggest me.
Thanks
It is not possible to do so in iOS. You can't send an app into the background
If you want your app to get displayed, the only way to do so is through push (from server) or local (from phone) notifications, and the user has to explicitly accept it.
Unfortunately, you can't make it open automatically.
iOS is not designed to run code in the background. There are a few exceptions, for example a music streaming app, or a GPS navigation app, but in general it cannot be done.
Instead, you should run your app on a server in the cloud, and send a push notification to the phone when you want something to happen on the phone. You may also be able to achieve this with "local notifications", depending on what you're trying to do.

Best practice for volume control iOS?

Hardware Volume Control
I'm trying to understand what is best practice for apps that are mostly silent but occasionally produce sound. Such apps can take advantage of the side volume control on iOS devices and avoid the need to design in a NSVolume control widget, which I believe is not as convenient as the hardware side volume control. The approach would apply to apps like MapQuest 4 mobile where you get occasional audio prompts that blend well with other music players (using audio ducking) but are silent for the most part. I'm wondering how others are addressing this same issue.
I have developed such a system that works rather nicely. In my approach I query the audio APIs to determine if other music is playing (iPod, AOL Radio, Pandora, etc.) then start an audio session only if no other audio is playing. This ties the hardware side volume control to the app instead of the ringer (for iPhones). The challenge comes when you go to the background. My approach kills (deactivates) the session in the background only if the app is not using audio. If there is audio playing the session is deactivated at the conclusion of the playback.
The idea behind killing the playback is to restore the user's ability to adjust the ringer volume to their liking should my app continue to run in the background.
This question originates from issues I faced when developing the voice navigation feature on MapQuest 4 mobile on iOS in 2008-2009. In this app we wanted the side volume switch to control the volume of the turn advice at all times while the app was running. I later realized that I could not control my ringer volume after arriving at my destination and sending the app to the background. This was years ago but I believe the app was continuing to run in the background which lead to the problem. It is an interesting case, when the user is navigating but sends the app to the background should you continue the audio session? Is is more likely that the user would like to change the app volume or the ringer volume while the app runs in the background?
My general use case (when I posted this question) involved navigating in the background while running another app in the foreground (commonly a music player). However it is also common for the navigation app to be sent to the background while the user sits on the home screen. This is when it would make sense to deactivate the audio session.
It is not as straight forward as it seems but my approach works for most cases. Still I am wondering if there are other more viable solutions to the problem. What are other people doing? Would it make more sense to just include the volume control in a view that auto slides in/out of place? Are there things that I have not considered? How have you approached the problem? Do you have any general suggestions?