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

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

Related

WebView in React-Native and popups

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?

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.

How to detect if a user comes from facebook or directly

let's say I have a website, which I'm also using as a facebook app (iframed page tab of a facebook page).
I need to know if the user has opened my site via the facebook app, or not, as I want to change some css and content only if opened in facebook.
Afaik I only get signed_request the first time the user opens the iframe on fb, so I "lose" it after the user navigates on my site.
Is there a better way to do this other than storing the signed_request in session?
Thanks in advance

Authentication within page tab by redirect instead of popup

How do I redirect a user who enters a Facebook page tab that runs a Facebook application (instead of a popup to the login page of my app) and then redirect back to page tab?
Oh ok,
You need to invoke the popup on user input. If the user clicked something like "Begin Game" or whatever on the landing page, it will not get blocked by popup blockers.
It has to be in an onclick or onmouseup event etc. That will bypass popup blocking.

Facebook Connect cancel button not working

I'm using facebook connect for a little website. This is my pop-up request URL:
https://www.facebook.com/dialog/oauth?client_id=".$app_id."&redirect_uri=".urlencode($redirect_url)."&scope=email,read_stream,publish_stream,publish_checkins,offline_access,friends_checkins,user_checkins&display=popup
The problem is, I have to buttons: Login and Cancel. When I click on cancel I go back to the login page, instead of closing the window. Any ideas?
Thanks.
This is a desired behavior of OAuth Dialog no matter which button user is clicks redirection (to URL specified in redirect_uri) occurs.
Some of the reasons that window isn't closed by clicking on Cancel and additional notes:
Closing of windows not opened by script is blocked in most browsers by default.
Closing of window is a feature that require JavaScript solution and OAuth dialog URL provides ability not to rely on this.
You can use JS-SDK with FB.login which will provide this for you and will close dialog.