open a facebook page -is it true? - objective-c

I
have read everywhere so many different things about opening the facebook app from another app, and some says its not official and can be changed ,some say its ok,
but anyway it doesnt work for me (and for many others-with broken pages)
i use :
NSURL *url = [NSURL URLWithString:#"fb://pages/MY-APP-PAGE"];
[[UIApplication sharedApplication] openURL:url];
its open the facebook app, but with a white page. on my mac- this link is working.
so, is this thing is real ?

since i KNOW many people know how to do that , and are not answering,
well , thats how its done :
NSURL *fanPageURL = [NSURL URLWithString:#"fb://profile/PAGE ID"];
[[UIApplication sharedApplication] openURL:fanPageURL];
Where PAGE ID is the long id number at the end of your facebook page .

Thanks for this answer.
To support more users, I used this one:
NSURL *nsurl = [ [ NSURL alloc ] initWithString: #"fb://profile/463560897057026" ];
if (![[UIApplication sharedApplication] canOpenURL:nsurl])
nsurl = [ [ NSURL alloc ] initWithString: #"http://www.facebook.com/SmileyGames" ];
[[UIApplication sharedApplication] openURL:nsurl];

Related

iOS: Instagram hook with special characters

I am trying to open Instagram from my app. The tag should contain some norwegian special characters, but the Instagram app is not lauching when I try to execute the code below. I tried with the code example below, and with UTF8 encoding, but without success. As soon as I add a tag without these characters, Instagram launches. Any tips on how to handle this characters?
NSString* hashtag = [NSString stringWithFormat:#"%#", #"instagram://tag?name=øæå"];
NSURL *instagramURL = [NSURL URLWithString:hash];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
Try with the percent escapes like this:
NSString* hashtag = [NSString stringWithFormat:#"%#", #"instagram://tag?name=%C3%B8%C3%A6%C3%A5"];

how to open phone app in iphone without using "tel://123" url [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Can I open phone app using url scheme in iPhone
Within app, I need to launch the phone app. I do not want to dial a call right away like the code below:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#\"tel://911\"]];
....which would just dial 911. I am wondering if I can just launch the phone app. I tried this code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#\"tel://\"]];
But it doesnot work
Please help me in solving this issue
You can't do that. However if you replace tel: with telprompt: it will prompt the user to confirm the call.
Edit: Also, #"a string" is the syntax literal for NSString. You shouldn't escape the quotes.
Try this code :-
NSString *prefix = (#"tel://123");
UIApplication *app = [UIApplication sharedApplication];
NSString *dialThis = [NSString stringWithFormat:#"%#", prefix];
NSURL *url = [NSURL URLWithString:dialThis];
[app openURL:url];
NOTE : Telephone number should be valid format only
Hope it helps you

Entering textfield values into an URL

So I'm in the progress of developing an app but I'm kinda stuck at the moment. I have 2 textfields right now that the user will have to enter:
Ordernr:xxxxxxxx
Referencenr:xxxxxxx
these 2 values have to be added to this link:
http://www.artis-web.de/cgi-bin/WebObjects/Artis.woa/wa/detailedTrack?referencenr=xxxxxxxx&ordernr=xxxxxxxxxx
now I want safari to open this link. The ideal situation would be the user entering the 2 textfields values and then pressing a button called "open in safari"
What would be the best way to implement this?
Just add the following code to your button action:
NSString *urlString = [NSString stringWithFormat:#"http://www.artis-web.de/cgi-bin/WebObjects/Artis.woa/wa/detailedTrack?referencenr=%#&ordernr=%#", referenceNrTextField.text, orderNrTextField.text];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: urlString]];
To create the URL you can use...
NSURL *url = [NSURL urlWithString:[NSString stringWithFormat:#"http://www.artis-web.de/cgi-bin/WebObjects/Artis.woa/wa/detailedTrack?referencenr=%#&ordernr=%#", referenceTextField.text, ordernoTextField.text]];
To open in safari...
[[UIApplication sharedApplication] openURL:url];
Check whether the both fields have data and then hit the url with the given data.This condition would be sufficient.
if (Ordernr.text.length!=0 && Referencenr.text.length!=0)
{
NSLog(#"Hit the Url with the entered data");
}
else
{
NSLog (#"Show Error Alert Message");
}

Xcode openURL doesn't read link

I have an animal list and special button. When I press the button, I would like to go to Wikipedia and read about this animal more. So I wrote this code:
-(IBAction)goWiki:(id)sender
{
NSString *wikiUrl = "http://ru.wikipedia.org/wiki/";
NSString *url = [NSString stringWithFormat:#"%#%#",wikiUrl,animalTitle];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:url]];
NSLog(#"%#",url);
}
NSLog shows that url was written correctly, however, nothing happened. I am 99,9% sure its because of animalTitle. My native language is russian and animalTitle is also an animal name in russian.
So if link is like http://ru.wikipedia.org/wiki/Frog its fine and it works but if its like
http://ru.wikipedia.org/wiki/Лягушка nothing happens.
Any ideas, how can I move to a russian article?
Thanks!
use stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding as follows -
-(IBAction)goWiki:(id)sender
{
NSString *wikiUrl = #"http://ru.wikipedia.org/wiki/";
NSString *url = [NSString stringWithFormat:#"%#%#",wikiUrl,animalTitle];
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:url]];
NSLog(#"%#",url);
}
Try passing the string animalTitle through CFURLCreateStringByAddingPercentEscapes first.

problem with loading a url into safari

I am using the below code to load a url into safari (iphone):
NSString *gotoURL = [self getPostID:indexPath.row];
//NSLog(gotoURL );
NSURL *url = [ [ NSURL alloc ] initWithString:gotoURL];
[[UIApplication sharedApplication] openURL:url];
the code works if I replace gotoURL with : #"http://www.example.com" but it wont if I replace it.
The gotoURL gets a url from getPostID (which also returns a NSString) and I did an nslog as you can see and the url format seems fine.
Any idea why its not working?
From what you've added, it is likely that you're missing the protocol in the url. The string passed must be http://domain.tld/4Mi.