we have an iPhone application that can share to Facebook but we have a problem with one of our share links (all the links use the same code).
The code is the following:
NSString *fullUrl = [NSString stringWithFormat:#"http://www.facebook.com/sharer.php?u=%#",
[campaignToShare.shareurl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:fullUrl]];
When we call the openURL method with the parameter: http://www.facebook.com/sharer.php?u=http://open.mikz.com/upvudd
we get it translated on safari (also opera) to the following url:
http://m.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fopen.mikz.com%2Fupvudd&_rdr
which does not work, however if use the url before the redirect to m.facebook (on the computer) then it works.
Is the code that we have written wrong or have we found a bug for iOS + m.facebook.com?
Obs: It works for all the other links that we have, the only differens on those links are that they have a different code (instead of upvudd).
Related
I am working with a custom iOS iPad application.
Every application in iOS can be treated as a web server (so to speak).
All over the net, I see that you can "call" Twitter from another app by using a hyperlink including "twitter://". What about other applications? Where is a repository from which to learn this information?
I want to use Safari and Adobe. Do I use safari://, or acrobat://?
Note: If you reply to this question by using any Code other than HTML or plain hyperlinks, you are completely wasting your time, my time, and anyone's time who will read your answer at a later date. Many people have asked this question only to get a whole bunch of great answers from smart people...only that the answers do not AT ALL match the question.
To open a web page in Safari, just use the openURL: function:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.google.com"]];
With Adobe, things are a little more complicated. I couldn't find a public URL scheme, so I downloaded the Adobe Reader app and looked at its Info.plist file. I found its URL scheme to be com.adobe.Adobe-Reader.
// I'm using a local file here, but it should also work with any remote PDF files
NSString *path = [[NSBundle mainBundle] pathForResource:#"SomeFile" ofType:#"pdf"];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"com.adobe.Adobe-Reader://%#", path]];
// Check to see if the user has Adobe Reader installed
if ([[UIApplication sharedApplication] canOpenURL:url]) {
// Reader is installed, open the PDF
[[UIApplication sharedApplication] openURL:url];
}
So your "plain hyperlinks" are http://www.google.com and com.adobe.Adobe-Reader://.
I have created a mail template on mailchimp. It consists of a twitter link. But an IPad or an IPhone user clicks on the link from his/her mail, the twitter link opens in the browser instead of the twitter app.
This does not happen in Android.
Any workarounds?
If you use a custom URL <a href="twitter://" than other Android/Desktop devices won't be able to open it. Twitter doesn't redirect with standard URLs from Safari and they should. But they do offer a "Open in app" button at the top left.
So if you want you could add two buttons in the email. One specifically for iOS: twitter://status?id=373205208664272897 and one for other devices https://twitter.com/support/status/373205208664272897.
Or you could create a site that reads the user agent of the device than determines which URL to redirect to.
The third option is just leaving it alone given that it's not really such a big issue in the grand scheme.
NSString *stringURL = #"twitter://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
From iPhone URL Schemes.
I am trying to share a link via Whatsapp and have read many tutorials as well. I am able to share my link successfully but the problem is that user doesn't come back to my app after sharing on whatsapp.
Here is the code I am using to share:
NSString *referralLink = [NSString stringWithFormat:#"some link here"];
NSString *textToSend = [[NSString stringWithFormat:#"whatsapp://send?text=%#",referralLink] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *whatsappURL = [NSURL URLWithString:textToSend];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
I know that I have to use URL Scheme to achive this and I have used it too. But I am not sure that I am using it in correct way.
Here is the screenshot of my .info file.
Behind the black bar, I have entered the bundle identifier. i.e com.abc.myapp
This is default behavior in iOS, only if the app developer of the app you are calling allows an option to send the user back to calling app will it work.
WhatsApp does not have such a feature and this is therefore not possible.
Also you should not use the whatsapp: url scheme in your apps info.plist. Doing this will make any app calling whatsapp: to open your app.
you should give your own url scheme(a unique identifier), probably your AppName. You are not supposed to use whatsapp
Now IOS 9 Do support the Apps to come back to the app when they are invoking any third party app being called using OpenURL scheme.
You can make a OS version based support at this moment unless you come to minimal support of IOS 9 for your application.
I'm working on something cool and I want to link to my Google+ profile in the iOS app.
Has anyone found out how to use the mgc:// URI scheme that the Google+ app on iOS provides to open a specific profile the way you can do it with fb://, twitter:// and almost every other account-based iOS app?
In fact it's really simple. Check your URL in a web browser and replace http:// or https:// with gplus://
Example :
If the URL in your browser is https://plus.google.com/u/0/100711776131865357077 then you open the profile in the app with the following code.
NSURL *gPlusUrl = [NSURL URLWithString:#"gplus://plus.google.com/u/0/100711776131865357077"];
if ([[UIApplication sharedApplication] canOpenURL:gPlusUrl]) {
[[UIApplication sharedApplication] openURL:gPlusUrl];
}
I know this is an old post, but I found the solution here (just search "google"). The URL scheme is gplus://. I have tested this myself and verified that it worked. Usage example:
NSURL *gPlusUrl = [NSURL URLWithString:#"gplus://"];
if ([[UIApplication sharedApplication] canOpenURL:gPlusUrl]) {
[[UIApplication sharedApplication] openURL:gPlusUrl];
}
I'm trying to link to a specific profile page in the Facebook iOS app by using the (semi-official) URL scheme.
fb://profile/123456789 works fine, but fb://profile/someusername does not. Am I missing something?
This URL works for me: fb://profile?id=<id> where <id> is either the numeric ID or the username.
Not sure whether facebook intends to keep this sort of thing constant, but here is the code that I use in my project. The FB link works on my iPhone (iOS 5) with one of the newer versions of the FB app.
Note that you need the numeric page ID to get the FB app link. This method worked for me: http://inlinevision.com/apps/how-to-find-your-facebook-page-id/
NSURL* direct = [NSURL URLWithString:#"fb://page/NUMERIC_PAGE_ID"];
NSURL* web = [NSURL URLWithString:#"REGULAR_OLD_WEB_LINK"];
if([[UIApplication sharedApplication] canOpenURL:direct]){
[[UIApplication sharedApplication] openURL:direct];
} else {
[[UIApplication sharedApplication] openURL:web];
}