Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any workaround to avoid "unsupported browser ..." when trying to use FB.ui on chrome on IOS

I am getting an "unsupported browser: chrome for ios doesn't support this feature. Please use safari and try again" when trying to open a share dialog by using the FB.ui API on an iphone.

I guess this question is related Facebook OAuth "Unsupported" in Chrome on iOS, but I am interested in sharing and not authentication by itself (ie I don't care if a user will login and I will not know about it).

like image 486
Mark Kaplun Avatar asked Nov 13 '14 19:11

Mark Kaplun


People also ask

Why is Facebook saying my browser is no longer supported?

The cause behind this issue is the FB Purity Chrome extension that you are using. Figured it out. It's the FB response to the Fluff Busting Purity Revert extension. Remove extension, problem gone.

What browser do I need for Facebook?

Google Chrome Chrome is currently the best browser you can use for Facebook. As the most used browser, Chrome is always compatible with the newest Facebook features. Facebook is the most used social media platform so they go hand in hand.


1 Answers

I know this is an old question but if anyone else faces this kind of problem, (I mean some googling got me here for a reason).

The facebook share dialog doesn't need a login to share.

https://developers.facebook.com/docs/sharing/reference/share-dialog

Usually you use the js sdk, like so:

FB.ui({
  method: 'share',
  href: 'https://developers.facebook.com/docs/',
}, function(response){});

Unfortunally this will not work in Chrome on iOs, but luckily there is a workaround for this (If you are using php);

$isIosChrome = (strpos($_SERVER['HTTP_USER_AGENT'], 'CriOS') !== false) ? true : false;
if ($isIosChrome == true) {
    $iosChromeShareLink = 'https://www.facebook.com/dialog/share
        ?app_id='.$settings['facebook']['appId'].'
        &display=popup
        &href='.urlencode($THE_SITE_U_WANT_TO_SHARE).'
        &redirect_uri='.urlencode($settings['facebook']['redirectUrl']);
}

So basically, you need to detect if the user uses Chrome on iOs and then replace your trigger element for the the FB.ui function with the "FB sharer"-link. Because you dont want to use the sharer all the time, only when the js sdk is not working.

And because every site on internet are treated as OG-objects by facebook you just need to make sure your site contains the correct OG-tags.

But if your facebook app(or site) require login for other purposes and you face the "unsupported browser" message by chrome, you could login your users thru the php redirect login (This require you to use the php sdk).

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;

/**
*FIXES CHROME ON IOS BUG
*
*
*/
$isIosChrome = (strpos($_SERVER['HTTP_USER_AGENT'], 'CriOS') !== false) ? true : false;
if ($isIosChrome == true) {

    FacebookSession::setDefaultApplication(
        $settings['facebook']['appId'],
        $settings['facebook']['secret']
        );
    $helper = new FacebookRedirectLoginHelper($settings['facebook']['redirectUrl']);
      $session = $helper->getSessionFromRedirect();
    if ($session) {
      //var_dump($session);
        $user_profile = (new FacebookRequest(
          $session, 'GET', '/me'
        ))->execute()->getGraphObject(GraphUser::className());
        $uid=$user_profile->getID;
        echo $uid;
    }
    else{
      $loginUrl = $helper->getLoginUrl();
      header("location:".$loginUrl);
      exit;
    }
}
like image 103
Jorgeuos Avatar answered Oct 25 '22 05:10

Jorgeuos