WebView in React-Native and popups - react-native

I am struggling with this issue for a while right now. I have an in-app browser, where I direct user to some webpage. In this webpage, there are popups, that are not working on in the WebView - they are not opening. I was trying to intercept them with onNavigationStateChange prop, and tried to navigate user to his native browser, but I've failed to do so - the popups never trigger any callbacks in the onNavigationStateChange. I was testing this using this webpage. My question boils down to:
Is is possible to intercept popups in the WebView, and if not - what approach can I take to make the popups available in the WebView or to somehow redirect user to his native browser, whenever the popup happens?

Related

React Native - Branch link in an Intercom message opens browser first instead of the app

I'm finding it hard to get Branch.io deeplinking to work with Intercom.
The Branch link works well when opened via native Messages app - opens the app directly when tapped.
But if we send this link through an Intercom message, and then tap on it on the phone, the result is not as expected:
On iOS
Open Intercom messages view.
Tap on the Branch link (sent from Intercom console).
Browser opens with an alert asking to open the native app ('Open this page in "MyApp"?').
Press "Open".
App detects the Branch parameters on the link and redirects to the correct page.
Expected Behavior
App should detect the link directly without being handed over by browser.
On Android
Open Intercom messages view.
Tap on the Branch link (sent from Intercom console).
List of suggested apps pops up - including "MyApp".
Tap on "MyApp".
App detects the Branch link ONLY, but without the parameters - which then will not redirect to any page.
Now send the app to the background (eg: Tap on home button), and then open "MyApp" again.
Branch will now detect the link with the parameters and redirect to the correct page (this sometimes happens in iOS as well).
Expected Behavior
Branch should detect the link with parameters directly, without the need to send the app to background and reopen.
Does anyone have an idea what I have missed out on? or a workaround?
I was thinking to setup Universal Links by uploading the Association File.. 🤷‍♂️
Btw, Branch.io configurations are all done and works perfectly with other social media apps.
react-native: 0.61.5
react-native-branch: 5.0.0-beta.1
react-native-intercom: 16.0.0

Website popup is blocked in react native webview

I want to integrate a website into a webview with react native.
Everything is fine until I want to login with facebook. When I press the "Login With Facebook" button, the webview become just a white screen and it is blocked.
This happens because when I press the login button, it tries to open a popup, but the popups are not enabled in react native webview.
So, my question is: how is possible to enable popups in webview? I just want my website to behave just like in a normal browser (like chrome, where everything is working fine), but inside my webview.
I use react native 0.55.
I read https://codeburst.io/webviews-and-social-authentication-with-react-native-cfecf96ac7d7 but didn't help me because I don't have access to the website source code.

How do I prevent a url from being displayed outside Messenger webview? e.g. directly in a browser

I'm working on an experience that should happen exclusively inside Messenger. How do I prevent an url from being displayed outside the webview. For example: user taps on 'Copy Link' and opens it in a browser.
Also, any way to disable the share button in a Messenger webview altogether?
There is no way to prevent the user from opening the link in another browser. Best you could do is detect the user agent on the page, then display an error that redirects to the bot and then resend a message with the URL button.
You can also set webview_share_button to false on the url button:
https://developers.facebook.com/docs/messenger-platform/reference/buttons/url

How to pass Login With Google Process in Cocoa WebView

I am developing a cocoa app for Mac OSX. It's a basic browser application and I use webview component.
In the page I want to connect, there is standard Login with Google Account button in order to login with my existing Google Account. When I clicked on this button nothing happens.
The same functionality works properly when I visited the same page by using Safari or any other browser but there is no reaction on webview component.
I've checked the action behind the Google's login button and here is the JS code.
onclick="return Dialog.Login.loginWithGoogle(false, 'https://www.mywebsite.com/-/oauth2callback', 'https://www.mywebsite.com/')"
As a part of the standard oauth process the process also has many redirections after this URL is called and normally should be completed at my site's login screen as expected. However, webview doesn't handle this.
Please note that the web site I am trying to connect in my webview is not belong to me and I have no control on it.
I checked many solutions on the web for 2 days but nothing helped.
Any help/hint will be appreciated.

Detect closing of mobile Safari

I'm building a WebApp which uses video server push with:
<img id="vidsrc" src="video.cgi"/>
It works. And when saved as a WebApp using "Add to Home Screen" closing the app does as expected and stop receiving the server push.
However when running in mobile Safari, only closing the page will get it to stop. What I'm trying to figure out is how to get it to stop if the user clicks the Home button and closes mobile Safari so the push doesn't keep running in the background.
Because of what I've got to work with, editing video.cgi is not an option. And using video.cgi in an iframe isn't a good solution because of some other functionality in the page/app.
onBlur and onClose don't seem to do it, and I'm wondering if there's any way an HTML page or the good stuff in it can know that mobile Safari has been closed.
Unfortunately, you can't... Web apps are not allowed to access the device's software, so are not told when you have pressed the button.