最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Open facebook page link in browser or native app correctly IOS cordova - Stack Overflow

programmeradmin1浏览0评论

Previous question on this similar topic isn't working for me and most of them are unanswered.

I want to take the user to a facebook page with button click. Updated facebook is installed in iphone, latest cordova is installed, inappbrowser plugin is used. Now my code is

window.open('', '_system','location=yes');

This works perfectly on android. But in IOS link is catched by nation facebook app and take me to the facebook wall of the use not the page feed. That means it just open the native app,but don't take to any page.

Then I searched, and tried some suggestions

window.open('fb://facebook/latechnologies', '_system','location=yes');

window.open('fb://pages/latechnologies', '_system','location=yes');

window.open('fb://pages', '_system','location=yes');

None of them are working. Every time it takes to the user wall. How can I simply take the user to the facebook page? Native app or browser doesn't matter. Just want to take the user to the page.....................

Previous question on this similar topic isn't working for me and most of them are unanswered.

I want to take the user to a facebook page with button click. Updated facebook is installed in iphone, latest cordova is installed, inappbrowser plugin is used. Now my code is

window.open('https://www.facebook.com/latechnologies', '_system','location=yes');

This works perfectly on android. But in IOS link is catched by nation facebook app and take me to the facebook wall of the use not the page feed. That means it just open the native app,but don't take to any page.

Then I searched, and tried some suggestions

window.open('fb://facebook.com/latechnologies', '_system','location=yes');

window.open('fb://pages/latechnologies', '_system','location=yes');

window.open('fb://pages', '_system','location=yes');

None of them are working. Every time it takes to the user wall. How can I simply take the user to the facebook page? Native app or browser doesn't matter. Just want to take the user to the page.....................

Share Improve this question asked May 22, 2014 at 9:12 AtanuCSEAtanuCSE 8,94015 gold badges79 silver badges115 bronze badges 1
  • @kathir cordova 3.4.1 – AtanuCSE Commented May 22, 2014 at 10:02
Add a comment  | 

5 Answers 5

Reset to default 8

For me using the Facebook page id instead of the page name works fine, e.g.

window.open('https://www.facebook.com/1401408870089080', '_system');

I know this is old but I had this problem too, and the accepted answer is through the browser, not through the FB app.

Answer = fb://profile/12323435435

On IOS pages are under 'profile'

fb://profile/   - FOR IOS
fb://page/      - FOR ANDROID

    <a onclick="window.open('fb://profile/INSERT_FB_ID_HERE','_system')"> 
                                        Your text or button here </a>

You can find a FB profile or page here : https://findmyfbid.com

Open up your MainViewController.m file.

Insert this code after @implementation and before @end MainViewController.

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL *url = [request URL];

    // Intercept the external http requests and forward to Safari.app
    // Otherwise forward to the PhoneGap WebView
    if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]){
        [[UIApplication sharedApplication] openURL:url];
        return NO;
    }
    else {
        return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
    }
}

After trying a few iterations and few of the suggestions above, the following code worked for me. window.open('fb://pages/, '_system');

The above is intended to open the page on facebook app (if it is installed).

Ofcourse, I have installed cordova inappbrowser plugin.

You need to install a plugin to open Apps: org.apache.cordova.inappbrowser 0.5.4 "InAppBrowser"

After that you must to know what is the Facebook Page Id, for this: https://graph.facebook.com/latechnologies

Take the ID number and replace the username of the Fanpage: https://www.facebook.com/1382616721988023

In that's all... ;)

Like Jonas's Answer! Different method! :)

发布评论

评论列表(0)

  1. 暂无评论