Can a metro app switch to last running app? - javascript

On button click I want to go back to the last running app, just like the back button on android or Alt+Tab. Is there a way to do that?

There is no programmatic way to the last running app specifically. However, if you know what the app is, you can activate it using a protocol handler, if it has one. E.g. If you got activated because of some flow, and you know you want to return to AppB, and AppB supports a protocol, you can use the launcher API to launch: "Appb://foo", and that app will open.

Related

How can I open a chrome tab on my laptop from my react-native app (like remote debugging does)?

I am creating a small debugging app to monitor a particular interaction (WebRTC) between two users of my main app.
I have a web app (React) and a mobile app (React-Native) that each connect through socket.io to a node server I created. This node server's purpose is to collect information from both users, and display this information in a web page in real time.
My web app has a button that when you click it it opens up that debugging web page in a new tab with the debugging information; I just use window.open. Is it possible to do something similar from my mobile device, running a react-native application? That is, can I click a button and have a browser tab open on my laptop somehow? Does React-Native remote debugging work with something like this?
There is currently no supported way you can do this in React Native.
However, you can certainly add it yourself.
Navigate to node_modules/react-native/local-cli/server/middleware/getDevToolsMiddleware.js
Look for launchChrome(debuggerURL);, you can invoke another launchChrome function with your desired URL.
This will only appear when you select Debug JS Remotely.
You can configure the CLI server code more to launch the URL when you are not debugging.

Handle silent push notification in closed react-native app (Android)?

I'm working on a react-native app that is closed the majority of the time. However, I need to be able to send updates from the backend to different clients so they can update local geofences.
I figured I could use silent push notifications for this (using FCM). This appears to work fine when the app is running (either in the foreground or background), but when the app is closed, I am unable to handle these push notifications.
I'm able to handle normal push notifications while the app is closed, because when the user presses the notification, the app is launched and the notification is available as the initial notification, but this isn't an option with silent notifications.
Is there any way to have my app handle silent push notifications while closed? Either by opening in the background, handling the notification, and closing or by registering some kind of background service?
You may want to take a look at react-native-push-notification#silent
Basically for android:
If your Android app is not running when a silent notification is received then this library will start it. It will be started in the background however, and if the OS starts your app in this way it will not start the react-native lifecycle. This means that if your notification delivery code relies on the react-native lifecycle then it will not get invoked in this situation. You need to structure your app in such a way that PushNotification.configure gets called as a side effect of merely importing the root index.android.js file.
And IOS:
The crucial bit of an iOS silent notification is presence of the "content-available": 1 field.

Cordova app terminate event

We want to be able to send a notification to the device when our app is terminated on user's device (not paused).
On iOS this is when you double click the home button and swipe up on the app, and Android this happens then you press the Menu button and swipe the app to the right.
In Cordova, there are the following events:
deviceready
pause
resume
backbutton
menubutton
searchbutton
startcallbutton
endcallbutton
volumedownbutton
volumeupbutton
activated
None of these events will fire when the app is terminated. The closest event is pause, this is fired when the app is terminated, but also when the app is moved into the background, and there isn't a way to tell which one is happening. Plus any processes that need to happen will only happen when the app is un-paused later.
My question is, how can my server know (or be notified) when you have terminated the app, in a reliable way. In order for me to be able to send a push notification.
This is not possible on iOS; the operating system may signal in advance with a low memory warning, but that doesn't mean the app will be terminated.
On Android, Cordova does not offer any support natively for this. You might be able to accomplish something with plugins and the information here: How to handle code when app is killed by swiping in android?

Save site as a mobile shortcut android

I spent a lot of time to search for solution but without result.
I check this topics :
Website Bookmark/ Shortcut Icon for Android Help. Cant get passed standard ribbon icon
Whick is very nice ,but here user must click on bookmark.That`s not what i need. May be button,or automatic script that prompt user for this and created automaticaly.For example something like this :
http://socialmedia.biz/2012/02/21/encourage-visitors-to-save-your-site-as-a-mobile-shortcut/
But it`s work only on Apple devices .. What im looking for is a similar solution for android.
Is this possible at all?
May be the only solution is to create simple app that act like a shortcut to my web page?
The page that is talking about has a mobile version ..
Have you looked here [for Chrome]? https://developers.google.com/chrome/mobile/docs/installtohomescreen
May be the only solution is to create simple app that act like a shortcut to my web page? The page that is talking about has a mobile version ..
If this is "allowed" and doesn't go against too many guidelines, this might be your only option. Basically you'd want to create a one Activity application and all it does is call the default Intent for your web page. This should push the user into the default Browser.
You could put the app in the Google Play store and link to it from the site or a script. I'd call the app something like "SITE_NAME Web Shortcut" and make it clear in the description that the only purpose is to launch the browser -- as previously mentioned this doesnt "feel" like something that should be in an app store, and if users think they're getting something extra you'll definitely get bad reviews.
(I'd also make the Activity with #style/Theme.Transparent)
Please be aware that Chrome has changed the way that installs web apps.
Here are the details: https://developers.google.com/web/updates/2018/06/a2hs-updates
There is an install criteria now:
The web app is not already installed
Meets a user engagement heuristic
Be served over HTTPS
Includes a Web App Manifest that includes:
short_name or name
icons - must include a 192px and a 512px icon
start_url
display - must be one of fullscreen, standalone, or minimal-ui
prefer_related_applications must not be present, or be false
-Registers a service worker with a fetch handler

Executing a Windows process from Windows 8 app using Javascript

I am working on a Windows 8 app where i want to execute a process with its parameters. Say "shutdown.exe"
I am working on the app in Javascript and HTML5. As far as i have researched it is not possible to do the same due to sandboxing (which i am not sure).
So is there a way to invoke a command process within a Windows 8 App ?
No. The closest thing is protocol activation, whereby an app can launch another via a URL. You can register an app to respond to any URI you want, but if someone else does the same, then your app won't run by default, and the user will be prompted to select which app they want to use to respond to the launch request.
You can check out how this works via the Application launching sample and the MSDN documentation.

Categories

Resources