Detect whatever screen off in react native - reactjs

I'm making an app which wants the user to keep the app open and not using other apps (to help them focuses on works), but allows them to turn the phone screen off. I used AppState API to detect if the app running in the background but it also triggered when the screen turned off. So I need a way to know if the screen is on or off. I tried googling around but I couldn't find any solution.

The short answer is that no RN library supports it for both platforms. For example, here you can find a solution for ios Detect screen on/off from iOS service and wrapper for RN react-native-lock-detection
However in your case, if we know that we receive a second event when the screen is off we can add a counter and when the app goes background the first time you increase the value if the second time you increase it again and add some logic. If the app goese active you reset this value.

Related

How to configure a specific setting of ios or android phone in th background if my react native app is open in foreground?

First of all I'm new as React-Native programmer. Currently I want to add a button to my React-Native(Expo) app, in which the user can turn off or on a setting. Is this possible and if so, how can I do that? For example in Android > Settings > Mobile Networks > Turn off mobile roaming?
Thank you in advance
I have tried to use HeadlessJS or a module called background actions. But there are no well documented examples and I also don't know if those modules answer my question. Because my task is more "straightforward" since I keep the app running in the foreground.

Force SPA Add to home screen popup to display even after adding to home

I am developing a PWA using react JS
There is a requirement that we need to display the add to Home screen even after the App has been added to the Home screen for the first time
Can any body suggest if this is possible and how?
INFO: Mostly this app will be run on Google Chrome and Safari
Refer to this answer. You simply can't do that, unless you want to do it in specific development/test machines where you can set the below chrome flag,
chrome://flags/#bypass-app-banner-engagement-checks
You can't expect all your end users to set this flag, so this can't be a solution for all the real users.
I also don't see why you would have to show the banner even after adding to home screen, for any other use case. Browsers don't allow this for obvious reasons. It will be annoying the user, if the prompting is left to developers. Linked answer have more clarification on the same.

How to get the current state of the tablet

Is there a way to get the current state of the tablet - if it is in sleep mode, in screen saver mode or if a picture is loaded - to get the name of the loaded picture for example. I didn't find anything in ALTabletService API, but judging on ALTabletService::resetTablet() - Reset the tablet as if no one used it before, i.e. clean the stack of activities, the web browser content, and the web browser cache. there is a stack of tablet activities and perhaps there is what I am looking for.
I don't think you can actually do that. You have to assume it's doing the right thing. If you need to check if your webview is loaded properly, why not raising an Event every 15s from the javascript and subscribe to it from Python? then as soon as Python does not receive this event for 15s, it can reload the page !

How to keep iOS native call UI after answering the call with CallKit

I am trying to achieve same results that can be seen on 29:52 second of Enhancing VoIP Apps with CallKit - WWDC 2016.
In that video it shows that after answering call the buttons are moved and changed by animation, and the screen stays in native in-call UI.
I built the Speakerbox and tried the "Simulate Incoming Call" function, but as soon as the call is answered by answer call button (the same action that is shown on video), the native call screen disappears and the application screen is shown with active calls shown in the list (which is different from what is shown in WWDC video):
Though there is a native call UI screen for very short time during transition from Incoming Call native UI to the app, but I can't find how to force it to stay on that screen.
Debugging the Speakerbox app there is no any delegate method called until all native screens are disappeared and the app is already opened.
I have tested receiving incoming call when the screen is locked, in that case the native UI is shown:
I would like to achieve same result on non locked phone.
Simply you can't keep native UI after accept incoming call, at least in iOS 10, maybe in iOS 11 Apple give a way to keep native UI.
If you lock the phone and then receive an incoming call, you will have similar experience to what you saw on WWDC. There is no a way to change this behavior in iOS 10.

Silverlight Notification API in-browser

I'd like to use the Notification API to create toast notifications for a Silverlight app designed to run both in and out of the browser, but the NotificationWindow class is only available OOB.
Does there exist anything that can replicate the behaviour inside the app? My idea is to have a container in the bottom right of the screen overlaying all other content. Then, create a wrapper which detects OOB-mode, passing params to the Notification API if possible, or populating and showing my own container if not. Is there anything that does this available?
It seems strange that MS chose not to implement something like this, as has been pointed out before.
Displaying a notification in browser is simple. You just need to use a popup and make it appear in the right place. See the following post as an example.
Now the difference with that approach is that the notification will show inside the browser. In OOB it shows outside the window and it's visible even if the windows is minimized. Due to security reasons it's not possible to directly do this.
Out of interest, Chrome Applications like Tweetdeck and Gmail, are able to display notifications outside of the browser. I think this might be a possiblity, but not exactly a Silverlight and cross browser solution.

Resources