para gratis descargar app aplicaciones aplicacion ios facebook

gratis - Abrir el enlace a la página de Facebook desde la aplicación de iOS



facebook app store descargar (6)

Después de muchas pruebas, encontré una de las soluciones más efectivas:

NSString *facebookID = @"XXXXXXXXXX"; NSString *facebookURL = @"www.facebook.com/XXXXXXXX"; NSURL *urlModal = [NSURL URLWithString:[NSString stringWithFormat:@"fb://facewebmodal/f?href=%@", facebookURL]]; NSURL *urlWithID = [NSURL URLWithString:[NSString stringWithFormat:@"fb://page/%@", facebookID]]; // or "fb://profile/%@" or another type of ID NSURL *url = [NSURL URLWithString:facebook_url]; if(facebookID && !facebookID.isEmpty && [[UIApplication sharedApplication] canOpenURL:urlWithID]) { // open facebook app with facebookID [[UIApplication sharedApplication] openURL:urlWithID]; } else if (facebookURL && !facebookURL.isEmpty && [[UIApplication sharedApplication] canOpenURL:urlModal]) { // open facebook app with facebookUrl [[UIApplication sharedApplication] openURL:urlModal]; } else if (![[UIApplication sharedApplication] openURL:url]) { // somehow open NSLog(@"%@%@",@"Failed to open url:",[url description]); }

El orden de las oraciones "if else" varía a tu gusto ...

¡¡Disfrútala!! :-)

Quiero redirigir al usuario a la página de Facebook de mi aplicación, así que tengo el siguiente código:

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @"https://facebook.com/myAppsPage"]];

esto funciona muy bien, si no hay una aplicación de Facebook en el dispositivo. Luego, el enlace se abre en Safari.

Si hay una aplicación de Facebook instalada en el dispositivo, luego de ejecutar el código anterior se abre la aplicación Facebook, pero muestra la línea de tiempo de los usuarios, no la página de mi aplicación. Traté de cambiar el enlace a @"fb://pages/myAppsPage" y a @"fb://profile/myAppsPage , pero esto de nuevo abrió la línea de tiempo de los usuarios.

Entonces, mi pregunta es: ¿cómo puedo abrir mi página de aplicaciones en Safari, si no hay una aplicación de Facebook, o en la aplicación de Facebook, si la tengo instalada?


Estuve feliz de encontrar la respuesta de skladek, así que aquí está mi contribución: Swift + otras redes sociales.

Descubrí que necesitaba 3 barras diagonales para Twitter, y solo 2 para Facebook y Google+, no investigué más que eso ...

// Go to https://graph.facebook.com/PageName to get your page id func openFacebookPage() { let facebookURL = NSURL(string: "fb://profile/PageId")! if UIApplication.sharedApplication().canOpenURL(facebookURL) { UIApplication.sharedApplication().openURL(facebookURL) } else { UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/PageName")!) } } func openTwitterProfile() { let twitterURL = NSURL(string: "twitter:///user?screen_name=USERNAME")! if UIApplication.sharedApplication().canOpenURL(twitterURL) { UIApplication.sharedApplication().openURL(twitterURL) } else { UIApplication.sharedApplication().openURL(NSURL(string: "https://twitter.com/USERNAME")!) } } func openGooglePlusPage() { let googlePlusURL = NSURL(string: "gplus://plus.google.com/u/0/PageId")! if UIApplication.sharedApplication().canOpenURL(googlePlusURL) { UIApplication.sharedApplication().openURL(googlePlusURL) } else { UIApplication.sharedApplication().openURL(NSURL(string: "https://plus.google.com/PageId")!) } }

Un intento de refactorización:

struct SocialNetworkUrl { let scheme: String let page: String func openPage() { let schemeUrl = NSURL(string: scheme)! if UIApplication.sharedApplication().canOpenURL(schemeUrl) { UIApplication.sharedApplication().openURL(schemeUrl) } else { UIApplication.sharedApplication().openURL(NSURL(string: page)!) } } } enum SocialNetwork { case Facebook, GooglePlus, Twitter, Instagram func url() -> SocialNetworkUrl { switch self { case .Facebook: return SocialNetworkUrl(scheme: "fb://profile/PageId", page: "https://www.facebook.com/PageName") case .Twitter: return SocialNetworkUrl(scheme: "twitter:///user?screen_name=USERNAME", page: "https://twitter.com/USERNAME") case .GooglePlus: return SocialNetworkUrl(scheme: "gplus://plus.google.com/u/0/PageId", page: "https://plus.google.com/PageId") case .Instagram: return SocialNetworkUrl(scheme: "instagram://user?username=USERNAME", page:"https://www.instagram.com/USERNAME") } } func openPage() { self.url().openPage() } }

Ahora puedes llamar:

SocialNetwork.Twitter.openPage()


Para iOS 9, debe incluir en la lista blanca las URL que llamará su aplicación utilizando la clave LSApplicationQueriesSchemes en su Info.plist.

Mira here .

<key>LSApplicationQueriesSchemes</key> <array> <string>fb</string> <string>fbapi</string> <string>fbauth2</string> <string>fbshareextension</string> <string>fb-messenger-api</string> <string>twitter</string> <string>whatsapp</string> <string>wechat</string> <string>line</string> <string>instagram</string> <string>kakaotalk</string> <string>mqq</string> <string>vk</string> <string>comgooglemaps</string> </array>


Parece que desde la última respuesta Facebook ha cambiado el esquema de las páginas (el perfil es el mismo que antes)

el page_id es ahora parte de la consulta URL. Entonces, para redireccionar a la aplicación fb, la url tiene que estar en el formato:

fb://page/?id=''your_page_numeric_id''

También asegúrese de Info.plist en la lista blanca el esquema fb en sus aplicaciones Info.plist

<key>LSApplicationQueriesSchemes</key> <array> <string>fb</string> </array>

En caso de que haya modificaciones adicionales o no conozca el page_id su página de Facebook, puede extraer la URL fb exacta de iOS de su fuente de la página web de Facebook.

  1. Abra su página de Facebook en Safari
  2. Haga clic con el botón derecho -> Inspeccionar elemento
  3. Buscar al:ios:url

Deberías poder encontrar:

<meta property="al:ios:url" content="fb://page/?id=''your_page_numeric_id''">

Copiando esta URL en su aplicación y luego llamando:

guard let facebookURL = NSURL(string: "fb://page/?id=''your_page_numeric_id''") else { return } if (UIApplication.sharedApplication().canOpenURL(facebookURL)) { UIApplication.sharedApplication().openURL(facebookURL) } else { guard let webpageURL = NSURL(string: "http://facebook.com/yourPage/") else { return } UIApplication.sharedApplication().openURL(webpageURL) }

debería hacer el trabajo.


Tienes que usar la identificación de Facebook para la página dada en lugar de la URL de la vanidad. Para obtener la ID de página, ingrese el nombre de su página en la siguiente URL y copie el valor de "id":

https://graph.facebook.com/yourappspage

Una vez que tenga la identificación, puede configurar el método para verificar si FB está instalado usando el método canOpenURL y servir el contenido apropiado para ambos estados:

NSURL *facebookURL = [NSURL URLWithString:@"fb://profile/113810631976867"]; if ([[UIApplication sharedApplication] canOpenURL:facebookURL]) { [[UIApplication sharedApplication] openURL:facebookURL]; } else { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://facebook.com"]]; }


Swift 2.3

Para el código puedes usar este ejemplo:

Nota: si no puede encontrar el ID de perfil de Facebook, puede usar el siguiente sitio para hacerlo ( https://findmyfbid.com/ )

func goFacebook() { let profileID = "" //Here put profile id Example:''62260589592'' let facebookURL = NSURL(string: "fb://profile//(profileID)")! if UIApplication.sharedApplication().canOpenURL(facebookURL) { UIApplication.sharedApplication().openURL(facebookURL) } else { UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/PageName")!) } }

Para Info.plist necesita establecer los siguientes parámetros:

Nota: para abrir Info.plist en modo fuente

-Vaya al archivo Info.plist y haga clic derecho

-Seleccione "Abrir como"

-Seleccione el "Código fuente"

-Put el código de arriba de otro

<key>LSApplicationQueriesSchemes</key> <array> <string>fb</string> <string>fbapi</string> <string>fbauth2</string> <string>fbshareextension</string> <string>fb-messenger-api</string> </array>