Sono sicuro che un'ora dopo averlo inviato potrei trovare la risposta, ma ho già cercato più di un'ora e non riesco a risolverlo. Quindi ecco qui ..Formato di gestori di URL di Facebook/Twitter di base
Vorrei inserire alcuni semplici collegamenti "Contattaci" nella mia app che apre il mio profilo in una di queste app di Twitter, se disponibili .... "Twitter", "Tweetbot", "Twitterriffic", o Facebook ricade su Safari se nessuno è disponibile. Non desidero aggiungere un'API completa per Twitter ecc., Poiché è semplicemente una pagina di contatto, non ho bisogno di accedere alle loro linee temporali, o conoscere il loro ID utente ecc.
L'APP di Tweetbot e il gestore che uso sul mio telefono funziona bene (vedi sotto) e apre la mia Pagina profilo, tuttavia non riesco a ottenere il lavoro predefinito di Facebook o Twitter, le applicazioni si avviano ma non riesco a raggiungere la pagina del mio profilo (ho ovviamente lasciato il codice di test, ma queste sono le linee che richiamano le applicazioni) ....
//Twitter
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://twitter.com/MyTwitterID"]];
//Tweetbot - WORKS!
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tweetbot:///user_profile/MyTwitterID"]];
//Fall Back to Safari - WORKS!
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.twitter.com/MyTwitterID"]];
//Facebook
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb://profile/MyFbID"]];
ora ho un bel po 'di informazioni here, ma sono in grado di farlo funzionare a parte per Tweetbot e Safari. Immagino che la parte dell'URL sia nel formato sbagliato, ma non riesco a trovarla da nessuna parte che spieghi come dovrebbe essere. La ricerca di Google genera pagine con tag twitter e facebook ma nessuna informazione utile, e la documentazione dell'API di Twitter è troppo dettagliata per la semplice implementazione che voglio fare. Qualcuno può aiutarmi con i giusti formati di URL?
[EDIT] mi ha portato più di un'ora, ma qui è a Twitter almeno ..
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://user?screen_name=MyTwitterID"]];
ancora lavorando sul Facebook uno !! Non posso prendermi il merito della risposta anche se mi sono imbattuto in esso here
Quando faccio funzionare anche Facebook, pubblicherò il mio codice qui con tutti i bit nel caso in cui aiuti qualcun altro!
plasma
EDIT 2: Ok ecco il mio codice (ho rimosso il mio URL del sito web e anche il mio facebook ID di ma si otterrà l'idea .... si apre un'interfaccia utente Azione Foglio con le opzioni Contattaci .. Spero proprio utile a qualcun altro.
#pragma mark - Contact Us Methods
- (IBAction)openContact {
UIActionSheet *popupContact = [[UIActionSheet alloc] initWithTitle:@"Contact Us" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Twitter", @"Facebook", @"Email", @"Visit our website", nil];
popupContact.actionSheetStyle = UIActionSheetStyleDefault;
[popupContact showInView:self.parentViewController.tabBarController.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *twitterUserName = @"MyTwitterName";
//Facebook ID (not the page name) check the FB urls for id=XXXXXXXXXXXXXXXX
NSString *facebookUserID = @"XXXXXXXXXXXXXXX";
UIApplication *app = [UIApplication sharedApplication];
switch(buttonIndex){
case 0: {
//Contact Us By Twitter
//Twitter Default
NSURL *twitterURL = [NSURL URLWithString:[NSString stringWithFormat:@"twitter://user?screen_name=%@", twitterUserName]];
if ([app canOpenURL:twitterURL])
{
[app openURL:twitterURL];
return;
}
//Tweetbot
NSURL *tweetbotURL = [NSURL URLWithString:[NSString stringWithFormat:@"tweetbot:///user_profile/%@", twitterUserName]];
if ([app canOpenURL:tweetbotURL])
{
[app openURL:tweetbotURL];
return;
}
// Tweetie: http://developer.atebits.com/tweetie-iphone/protocol-reference/
NSURL *tweetieURL = [NSURL URLWithString:[NSString stringWithFormat:@"tweetie://user?screen_name=%@", twitterUserName]];
if ([app canOpenURL:tweetieURL])
{
[app openURL:tweetieURL];
return;
}
// Birdfeed: http://birdfeed.tumblr.com/post/172994970/url-scheme
NSURL *birdfeedURL = [NSURL URLWithString:[NSString stringWithFormat:@"x-birdfeed://user?screen_name=%@", twitterUserName]];
if ([app canOpenURL:birdfeedURL])
{
[app openURL:birdfeedURL];
return;
}
// Twittelator: http://www.stone.com/Twittelator/Twittelator_API.html
NSURL *twittelatorURL = [NSURL URLWithString:[NSString stringWithFormat:@"twit:///user?screen_name=%@", twitterUserName]];
if ([app canOpenURL:twittelatorURL])
{
[app openURL:twittelatorURL];
return;
}
// Icebird: http://icebirdapp.com/developerdocumentation/
NSURL *icebirdURL = [NSURL URLWithString:[NSString stringWithFormat:@"icebird://user?screen_name=%@", twitterUserName]];
if ([app canOpenURL:icebirdURL])
{
[app openURL:icebirdURL];
return;
}
// Fluttr: no docs
NSURL *fluttrURL = [NSURL URLWithString:[NSString stringWithFormat:@"fluttr://user/%@", twitterUserName]];
if ([app canOpenURL:fluttrURL])
{
[app openURL:fluttrURL];
return;
}
// SimplyTweet: http://motionobj.com/blog/url-schemes-in-simplytweet-23
NSURL *simplytweetURL = [NSURL URLWithString:[NSString stringWithFormat:@"simplytweet:?link=http://twitter.com/%@", twitterUserName]];
if ([app canOpenURL:simplytweetURL])
{
[app openURL:simplytweetURL];
return;
}
// Tweetings: http://tweetings.net/iphone/scheme.html
NSURL *tweetingsURL = [NSURL URLWithString:[NSString stringWithFormat:@"tweetings:///user?screen_name=%@", twitterUserName]];
if ([app canOpenURL:tweetingsURL])
{
[app openURL:tweetingsURL];
return;
}
// Echofon: http://echofon.com/twitter/iphone/guide.html
NSURL *echofonURL = [NSURL URLWithString:[NSString stringWithFormat:@"echofon:///user_timeline?%@", twitterUserName]];
if ([app canOpenURL:echofonURL])
{
[app openURL:echofonURL];
return;
}
// --- Fallback: Mobile Twitter in Safari
NSURL *safariURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://mobile.twitter.com/%@", twitterUserName]];
[app openURL:safariURL];
return;
}
case 1: {
//Facebook
NSURL *facebookURL = [NSURL URLWithString:[NSString stringWithFormat:@"fb://profile/%@", facebookUserID]];
if ([app canOpenURL:facebookURL])
{
[app openURL:facebookURL];
return;
}
// --- Fallback: Mobile Facebook in Safari
NSURL *safariURL = [NSURL URLWithString:@"https://touch.facebook.com/MyFBName"];
[app openURL:safariURL];
return;
}
case 2:
//Email
[app openURL:[NSURL URLWithString:@"mailto://[email protected]?subject=Important%20Email&body="]];
return;
case 3:
//Visit The Website
[app openURL:[NSURL URLWithString:@"http://www.mywebsite.co.uk"]];
return;
case 4:
//Cancel
return;
}
}
Non v'è alcuna necessità di questo passo, perché ho già controllare per vedere se le applicazioni sono lì con .. se ([App canOpenURL: tweetbotURL]), se il gestore URL non è presente, allora il l'app non è installata – Plasma
@Plasma oh capisco! Grazie per il codice. È stato davvero utile –