Can you communicate to a native mobile app from mobile web browser? - javascript

I want to find a way to run native mobile app, from a web app on a browser, and communicate the result back to it.
For example, how does Facebook user authentication work on a mobile device? You go to login with Facebook on a website. If on mobile, it opens the native Facebook app to do the authentication, and redirects the user back to the mobile web browser to open some page, post-authentication. Somehow, web browser and native application are able to communicate? Is there also any security risk to this?

One way to do this is as follows:
Use a custom url to launch the app from the website (see link below)
Pass whatever parameters you need to the app (for example a return web site URL in the case of a login authentication type app)
Once the app launches and does it thing, have the app launch a browser using the return address URL you passed as a parameter to the app.
A good, well maintained, link to using custom URL's and passing partakers to the App:
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

Related

Prevent Twitter Auth URLs from opening native Twitter App

I'm using a react-app that uses Twitter's OAuth API which grants access to a user's Twitter account. However, when the app is used on mobile it only opens the auth URL in the native Twitter app rather than on the browser. An example URL would look like this:
https://twitter.com/i/oauth2/authorize?response_type=
Is it possible to add a parameter in the URL above so that mobile phones know not to open it in the native Twitter app? If not, is there anything I can do with things like window.location, window.document.location, window.location.assign, window.location.replace to prevent this from happening?

Chrome opens PWA automatically when opening the site

I have a web application that can be installed as PWA. Once installed the problem appears on Android devices with Chrome.
If a user is logged out the application will redirect to an authentication service that is hosted on a separate server. Once a user has logged in the application redirect him to main page of app. PWA is opened automatically at this point. I don't want this.
Does anybody know a way to prevent automatically opening PWA when a user open a site in browser?
It was noticed on Android 8.0 with Google Chrome 74.0.3729.157.
Also if an authentication page is rendered inside iframe PWA is not opened automatically.
Finally I get it.
PWA is installed as WebAPK so Android open my application automatically when an auth server returns redirect to my application https://developers.google.com/web/fundamentals/integration/webapks.
A way exists to prevent that by defining a scope parameter in manifest.json. But it is not my case because all my application is in the root.
Finally I use iframe to render an auth page instead of redirection to auth service directly.

How can I call JavaScript function on web page (not webview) that opened Android app?

We have customers who need to be able to talk to a device connected to the audio jack. Our customers can do web development but not android development.
Our goal was to create an app that stood between the web app and the SDK that talked to the audio connected device. I have code that launches our android app and our activity. I need to be able to send data back to the web page that opened our android app; preferably with a callback to a JavaScript function.
I can't use a webview because it is the customer's site (would be used with many customers and their respective sites). I thought about using local storage but I don't want the web page to get "stale" data saved from a previous call to the application.
Is it possible for an Android app to execute a callback function on a web page that loaded the Android app via an intent link? I have been feverishly searching and I can't seem to find anything.
I have called functions in a page loaded in web view but it will be an external page calling our application and need to send information back to that page.
I have examined the Intent object in the activity and can't anything I can hook into.

Redirect user from iOS browser to App if installed, or to App Store if not - like Yelp

How can I detect whether the user browsing to my website has installed my app, and redirect to it on the click of a button in the banner like yelp?
I only need help with the detecting and redirecting from the browser. Yelp manages to do it. I tried messing with universal links, but I'm not sure how to detect that the user does not have the app and to then redirect him/her to the app store.
Yelp uses a company called Branch (Full disclosure, I work there). We have some complicated infrastructure that allows us to tell when a particular device has the app installed or not.

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.

Categories

Resources