Is there a way to force WebView link clicks to open externally? - react-native

I've got a WebView component that's loading static HTML content:
<WebView
style={{flex: 1}}
html={content}
/>
The issue is, if someone taps a link, it opens in the app and I'd rather force it to use Linking to open in Safari. Is that possible?

After searching around a bit the only way I see to open a browser from an RN app is using the Linking or LinkingIOS API. The question then is, how to enable your Webview to use that API. Here are two possible solutions:
1) Register your own URL Scheme that is handled by your app. E.g. myApp://this/is/a/link.html. Then handle all incoming events for that scheme and make corresponding calls to the API. Registering a scheme is easy and works very well. That seems like the most robust method to me.
2) Use a library that lets the Webview directly talk to it's paren view. E.g. https://github.com/alinz/react-native-webview-bridge.
Then you put a little JS code in your page that onClick sends the link URLs to the parent view, that then calls the API. I have used that project a while ago and it work like a charm until one RN upgrade that I needed broke it. But it's still under active development so you should be fine.

Related

Display compiled Angular app inside React Native

The company I work for has many small angular applications they would like to make available in an phone app. Mostly because the users are usually in poor connection places so it would be nice if they only need to make the API calls and not load resources, and they also want to be able to make push notifications for new events.
So looking into this I'm trying to see if its possible to embed Angular (v13 as of now) applications inside of React Native. Where the react app will mostly act as a menu and notifications handler.
To be honest I haven't found much help online besides that I probably need to use a <WebView>. So i tried compiling a simple Angular app and placed it in /assets/my-app/
and then tried the following (with a few variations on how I wrote the URL).
<WebView source={{uri: '~/assets/my-app/index.html'}} style={{marginTop: 20}} />
But that did not work at all.
So, my questions are:
Can this be done?
Is this the right method?
How do I accomplish this?
Thank you

Init with push vue router, back button not working

The problem seems easier but not working, im working over a spa on webview for apps.
So for example, in some cases I start the web with a main route, like 'localhost/path1/path2'.
So if they press a custom button in topbar (custom component), it goes to 'localhost/path1', here perfect.
The problem is when they press the native back button, or the back arrow in desktop (native).
What happen here is the app is closed or the url is empty in desktop.
I tried to force a push in many ways on load vue with many paths, but not working, I tried to intercept native back and force push to avoid close first time with many paths, but not working anyways.
If someone understand what Im saying and a solve for urls with path/id, and after native back just keep path, instead of close I hope you can help.
Thanks

how to navigate between webview pages described in different files

Good day, I have such a problem. The application is made on the basis of webview, at the beta stage. And I faced such a problem that after the registration stage I need to launch a separate page in which the native elements and the webview are combined. Please give a tip on how to cope with this task
U.P.D The crux of the problem is this. I have a file that describes one webview page. I need to make sure that after the user is registered, he is thrown to another file, where the webview is also described, but in addition to the webview there are native menu elements for the user to navigate the application. If it's not clear, I can try to make a block diagram, maybe this will be clearer

Can I create a Whitelist for Safari using OpenUrl in Xamarin.Forms?

I am working on a project using Xamarin.Forms as a container app. This app includes several webviews that link to restricted web content. One of these links our Sharepoint site. The Sharepoint site has a link that allows our users to go to a 3rd party site(Cornerstone) to view training videos. When using the stock UIWebView, WKWebView, or SFSafariViewController the popup that displays the video is not shown. The only way that I can get this video to play in my app is to use OpenURL to open the Sharepoint site in Safari. The problem is that this is an Enterprise solution where we don't want to allow the employees free reign with the browser.
Is there a way to create a whitelist or to have some control over the searchbar or read the url that they are linking to and block it or redirect the user?
Unfortunately as it's farming out the URL Navigation external to your application there's not a lot you can do from within your app to restrict what they do after the fact, 'openURL' only returns a Boolean value as to it's success, and the only parameters that you can send to it are:
application - Reference to this application
(UIApplication.SharedApplication).
url - The NSUrl specified by the
calling application.
sourceApplication - The bundle ID of the calling
application.
annotation -Optional property-list data passed by the
calling application.
You can only access these if you override the 'openURL' method within your 'AppDelegate.cs' class, there is a set of options you can pass through as an override but again none of those allow you to restrict what the user does after the browser has opened.
If the devices are managed using something like 'meraki' or some other software to control the use of managed devices, then you would likely set up a 'group policy' styled set of restrictions however that's not really a Xamarin issue, and should be discussed with the network administrators.
That being said, I don't see any reason why you can't use the WebView1, that way you can handle it all within your application. Or alternative utilize custom renderers and pass in the direct video urls and commit to opening up the devices media player for streaming the content2.
1 Playing videos in WebView
2 Using the media manager plugin.

Swap the application in Objective-C?

I'm developing iPad application I need to integrate third party project(Source code) with my code like i have a button in my code, when i click on the button it landed to third party application page then navigate around and vice verrsa. what is the best way to swap the app?
Regards,
Sri
Use the url schema.
See add custom URL Schema using http://
Every Application can have customer url schemas. Like ...
yourapp://someting?withparams=1.
To get they running you have to change your Info.plist to inform the iOS that your app is handling that url schema. See the SO post above.
When another App calls that URL your app gets opened and you get a hook on your app delegate.
check http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007899
and:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIApplicationDelegate
Also look here:
http://wiki.akosma.com/IPhone_URL_Schemes