strange openURL with Facebook and Twitter

Hi all,

Something strange on my iphone using system.openURL :

Facebook : open MYPAGE in my browser ( whereas i have the fb app on my phone ) :

    system.openURL("https://facebook.com/MYPAGE")

Twitter : open MYPAGE on the twitter app on my iphone :
    system.openURL("https://twitter.com/MYPAGE")

Is it the same result for you with facebook and twitter ?

and on android ?

What are you seeing?

With the same code, fb open the browser whereas twitter directly open the webapp (which is cool).

Why fb doesn’t directly open the fb webapp too ?

That would be a behavior determined by the operating system. Perhaps a Google search on “open facebook app with openurl” will yield you some useable results. Our system.openURL() is just calling the iOS or Android version of the call. We just pass the URL to the system call.

Rob

Indeed rob, the link to open a fb page directly in the app via openurl seems to be : fb://profile/xxxxxxxxxxxx and xxx is your pageid. I have to test this monday. But what if the user has no fb app ? An error occurs then? And is there a prompt “do you want to open this fb link in the app?”… Answer in 2 days :slight_smile:

You can call system.canOpenURL() to see if you can open it or not, if it returns falls, fall back to opening the web browser version.

Rob

hi all,

i use the following code now :

local my\_fb\_id = 111111111111 local my\_urlfb = "mypage"     if ( system.canOpenURL( "fb://profile/" .. my\_fb\_id ) ) then       system.openURL( "fb://profile/"..my\_fb\_id ) -- open in webapp     else       system.openURL(my\_urlfb) -- open in browser     end

and i have modify my build.settings like that :

settings = {     iphone =     {         plist =         {             LSApplicationQueriesSchemes = { "fb" },         },     }, }

now, it works perfectly on ios, but NOT on android… grrrrr… blank page… any idea ?

I have added the following in build.settings, but android always show “content non available” in the facebook webapp…

settings = {     android =     {       intentFilters =     {        {           label = "Facebook", -- Optional Title Goes Here           actions = { "android.intent.action.VIEW" },           categories =           {              "android.intent.category.DEFAULT",              "android.intent.category.BROWSABLE",           },           data = { scheme = "fb" }, -- for fb:xxxxxxxxxxx        },        -- You can add more intent filters here.     },           }, }

Hum… this is not the good solution.
Indeed, android well open the Facebook app with the fb:xxxxx link, but doesn’t sucess to open the ask page, just showing : “content non available”.
Whereas it’s ok on iOS for the same link. I don’t understand why…

It seems that for android the url format should be : “fb://facewebmodal/f?href=” + url

    local fbPageID  = "1044933568990607" -- your page id : STRING MANDATORY     local fbPageURL = "https://m.facebook.com/"..fbPageID     local platform = system.getInfo( "platform" )     if platform == "android" then -- android              local fbPageURL\_androidApp = "fb://page/"..fbPageID       if ( system.canOpenURL(fbPageURL\_androidApp) ) then         system.openURL(fbPageURL\_androidApp) -- open in native app       else         system.openURL(fbPageURL) -- open in browser       end            elseif platform == "ios" then -- ios              local fbPageURL\_iosApp = "fb://profile/"..fbPageID       if ( system.canOpenURL(fbPageURL\_iosApp) ) then         system.openURL(fbPageURL\_iosApp) -- open in native app       else         system.openURL(fbPageURL) -- open in browser       end            else       system.openURL(fbPageURL) -- open in browser     end

Hi created this code and it works for me, opening my fb page in the native fb app on ios or android.

This is my contribution, hope it helps someone :slight_smile:

What are you seeing?

With the same code, fb open the browser whereas twitter directly open the webapp (which is cool).

Why fb doesn’t directly open the fb webapp too ?

That would be a behavior determined by the operating system. Perhaps a Google search on “open facebook app with openurl” will yield you some useable results. Our system.openURL() is just calling the iOS or Android version of the call. We just pass the URL to the system call.

Rob

Indeed rob, the link to open a fb page directly in the app via openurl seems to be : fb://profile/xxxxxxxxxxxx and xxx is your pageid. I have to test this monday. But what if the user has no fb app ? An error occurs then? And is there a prompt “do you want to open this fb link in the app?”… Answer in 2 days :slight_smile:

You can call system.canOpenURL() to see if you can open it or not, if it returns falls, fall back to opening the web browser version.

Rob

hi all,

i use the following code now :

local my\_fb\_id = 111111111111 local my\_urlfb = "mypage"     if ( system.canOpenURL( "fb://profile/" .. my\_fb\_id ) ) then       system.openURL( "fb://profile/"..my\_fb\_id ) -- open in webapp     else       system.openURL(my\_urlfb) -- open in browser     end

and i have modify my build.settings like that :

settings = {     iphone =     {         plist =         {             LSApplicationQueriesSchemes = { "fb" },         },     }, }

now, it works perfectly on ios, but NOT on android… grrrrr… blank page… any idea ?

I have added the following in build.settings, but android always show “content non available” in the facebook webapp…

settings = {     android =     {       intentFilters =     {        {           label = "Facebook", -- Optional Title Goes Here           actions = { "android.intent.action.VIEW" },           categories =           {              "android.intent.category.DEFAULT",              "android.intent.category.BROWSABLE",           },           data = { scheme = "fb" }, -- for fb:xxxxxxxxxxx        },        -- You can add more intent filters here.     },           }, }

Hum… this is not the good solution.
Indeed, android well open the Facebook app with the fb:xxxxx link, but doesn’t sucess to open the ask page, just showing : “content non available”.
Whereas it’s ok on iOS for the same link. I don’t understand why…

It seems that for android the url format should be : “fb://facewebmodal/f?href=” + url