How to add links in device settings for our app? - ios

I have to add my website link in iPad settings for our app. I know how to add simple text but don't know how to add links so that clicking on it safari will open.
Same as done in facebook / twitter app for "learn more about facebook/twitter"
I have checked this url but didn't find how to add URLs.

Write the following code to your action method of setting row/button
NSURL *yourLinkURL = [[NSURL URLWithString: #"https://www.google.co.in" ];
[[UIApplication sharedApplication] openURL: yourLinkURL];

You can't do that with the settings bundle. The only reason Facebook and Twitter have it is because they are more integrated with the system, so they run a special settings bundle that normal developers don't have access to.

Related

App not opened programmatically?

I installed Meeseva app on my device. When I try to open it programmatically it's not opening.
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"Meeseva App://location?id=1"]]) {
NSString *mystr=[[NSString alloc] initWithFormat:#"Meeseva App://location?id=1"];
NSURL *myurl=[[NSURL alloc] initWithString:mystr];
[[UIApplication sharedApplication] openURL:myurl];
}
When I opened fb, twitter, google+ and etc... all are opening successfully.
Can any solve this this issue?
App link is
https://itunes.apple.com/in/app/meeseva-app/id1121539928?mt=8
Is there any another way to open installed app programatically?
If your app can receive specially formatted URLs, you should register the corresponding URL schemes with the system. Apps often use custom URL schemes to vend services to other apps.
Hence "Meeseva" app might not have created a custom url for their app. So you can't do anything for it.
As mentioned above the apps which want to provide support for url schema then they have to create a custom URL schemes.
You need to find out what the correct URL scheme of the Meeseva App is. Meeseva App:// does not seem to be a valid URL scheme as it has a space in the middle.
For example the Google Maps URL scheme is comgooglemaps://, not Google Maps://
Usually developers make their URL scheme public in their documentation. However this is a feature that needs to be implemented and apps don't support this "out of the box". If the developer did not implement this, the app can't be opened via link.
Alternatively it is possible that the app reacts on "universal links". That means if there is a website for the app, iOS might ask you whether to open that website in the app or in Safari. In that case you could simply link to the website and let the user decide how the link should be opened. However, again, this needs to be implemented by the developer. If the app does not support universal links either, there's no way for you to open the app at all.

Opening another (mine) application from my main application Swift

I have two applications and i want to open them from each other (like facebook opens messenger).
After a little search i found that i have to know the url scheme of my app, but i don't know how can i declare it. In my urlSchemes are only facebook's schemes.
var url = NSURL(string: "")
UIApplication.sharedApplication().canOpenURL(url!)
I found that code and as i understand i have to put in the url my urlScheme.
Any help?
Here is a good tutorial on setting up URL Schemes within you app: https://dev.twitter.com/cards/mobile/url-schemes
Incase this tutorial disappears, heres the info:
Configure our Xcode project
Go to Your Target > Info > URL Types
You need to define your custom URL type. Remember, you want to open the app via birdland://, so that will be your URL scheme. We also need to assign an unique identifier to the scheme. Apple recommends that you use reverse DNS notation to ensure that there are no name collisions on the platform, e.g com.mycompany.ios.
That’s it! You’ve configured the app with simple support for the URL scheme birdland://. There is, of course, much more that you can do with Custom URL Schemes. To find out more, check out Apple’s documentation.
Now, to check that our registered URL scheme works, we’ll head out to Safari. Press the “Home” button in the Simulator (or press command-shift-H) to reach the Home Screen. Open Safari.
Next, type birdland:// in the address bar of Safari. Just as you can with http:// URLs, you’re asking Safari to open the “birdland” scheme. Press Go.
NSString *openAppURL = #"yourappname://";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:openAppURL]];
//check if app is installed or not
BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:openAppURL]];

How to open ios app using url?

I want to open my ios app using URL schemes. I am able to open app using this.
But I want if app is not installed then app store should be opened where user can download app.
Is this possible? How can I do that?
EDIT
Explaining question step wise:
I have a mail in my inbox with a url.
I click on URL then
i. If app is installed in phone, app will launch.
ii. Otherwise app store will be opened to download app.
Thank
I handled it via my server side code:
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("com.myapp://");
setTimeout(function() {
if (!document.webkitHidden) {
location.replace("https://itunes.apple.com/app/xxxxxxxx");
}
}, 25);}
else if ((navigator.userAgent.match(/android/i)) || (navigator.userAgent.match(/Android/i))) {
location.replace("https://play.google.com/store/apps/details?id=packagename&hl=en");}
else {
location.replace("http://www.example.com");}
I put this in my www.mysite.com/download page & share this url via campaigns.
What you're describing is called Deferred Deep Linking (Deep Linking refers to using a link to open your app, even directly to a specific piece of content, and Deferred means that it works even if the app isn't installed first).
Unfortunately there's no native way to accomplish this yet on either iOS or Android. URL schemes don't work, because they always fail if the app isn't installed. Apple's new Universal Links in iOS 9 get closer, but you'd still have to handle redirecting the user from your website to the App Store
A free service like Branch.io (full disclosure: they're so awesome I work with them) can handle all of this for you though. Here's the docs page covering exactly how to create email links like you described: https://dev.branch.io/features/email-campaigns/overview/
If your App is not installed in device then, you can open app store using below lines of code:
NSString *iTunesUrlofApp = #"itms://itunes.apple.com/us/app/apple-store/...";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesUrlofApp]];
Try below code:
if([[UIApplication sharedApplication] canOpenURL:url]){
// Means your app is installed, and it can be open
[[UIApplication sharedApplication] openURL:url];
}
else{
//Your app is not installed so, Open app store with your apps iTunes Url
NSString *iTunesUrlofApp = #"itms://itunes.apple.com/us/app/apple-store/...";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesUrlofApp]];
}
After iOS 5 you can also use https:// to avoid redirections.
Edit:
Check the link to open app from url if installed: Universal links to open app from Url.

Open Link on Twitter App IOS

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.

whatsapp URL Scheme doesn't give control back to app.

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.

Resources