Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?
I think the least intrusive way of doing this is as follows:
- Check if the user-agent is that of an iPhone/iPod Touch
- Check for an
appInstalled
cookie - If the cookie exists and is set to true, set
window.location
toyour-uri://
(or do the redirect server side) - If the cookie doesn't exist, open a "Did you know Your Site Name has an iPhone application?" modal with a "Yep, I've already got it", "Nope, but I'd love to try it", and "Leave me alone" button.
- The "Yep" button sets the cookie to true and redirects to
your-uri://
- The "Nope" button redirects to "http://itunes.com/apps/yourappname" which will open the App Store on the device
- The "Leave me alone" button sets the cookie to false and closes the modal
- The "Yep" button sets the cookie to true and redirects to
The other option I've played with but found a little clunky was to do the following in Javascript:
setTimeout(function() {
window.location = "http://itunes.com/apps/yourappname";
}, 25);
// If "custom-uri://" is registered the app will launch immediately and your
// timer won't fire. If it's not set, you'll get an ugly "Cannot Open Page"
// dialogue prior to the App Store application launching
window.location = "custom-uri://";
How to define url schemes starting with http ios7
Short answer: You can't without server support. Apple does tricks that are not available to third party apps to redirect HTTP URLs like Maps and Youtube.
The only way you could do this would be to set up a web server at http://a.myapp.com
that redirected to myapp://
Open URL Schemes in IOS
You have 2 Apps.Now you want to open First App from the Second App.I will give you the step by step instruction please follow that.
My First application name is LinkAppSample and Second application Name is LinkSecondApp
STEP 1: Add the below things in first app LinkAppSample
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.example.com</string>
<key>CFBundleURLSchemes</key>
<array>
<string>chatapp</string>
</array>
</dict>
</array>
Then you need to add
<key>LSApplicationQueriesSchemes</key>
<array>
<string>chatapp</string>
</array>
See the below screenshot below
STEP 2: Go to Second App.My Second App Name is LinkSecondApp.Now click LinkSecondApp project.Click TARGETS and click
info.Then Click URL Type and add or write or set name in URL Schemes
Target->Info->URL types->Add url types
First Click Info of Targets
Then click URL Tpes.Once you click it shos you the + symbol.
Now click + symbol and give the name of the app in URL Schemes.You must set Rote as Viewer
NOTE:Your URL Schemes name must be same(First App Plist Name and Second App URL Schemes name is chatapp here).
STEP 3: Now you must add code in Second application LinkSecondApp for
opening the First app.
LinkSecondApp.m
-(IBAction)actionOpenFirstApp:(id)sender
{
NSString *customURL = @"chatapp://";
UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:@"chatapp://"];
if ([application respondsToSelector:@selector(openURL:options:completionHandler:)])
{
[application openURL:URL options:@{}
completionHandler:^(BOOL success) {
NSLog(@"Open %@: %d",customURL,success);
}];
}
else {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error!" message:@"No Custom URL is defined" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:nil];
}
}
Related Topics
Send Messages Between iOS and Watchos with Watchconnectivity in Watchos2
Color All Occurrences of String in Swift
Core Data Multi Thread Application
How to Remove Cache in Wkwebview
Wrapping Text in a Uitextview Around a Uiimage Without Coretext
Waiting for Multiple Asynchronous Download Tasks
How to Maintain Presenting View Controller's Orientation When Dismissing Modal View Controller
Could Not Load the "" Image Referenced from a Nib in the Bundle with Identifier
How to Add Different Types Conforming to a Protocol with an Associated Type to a Collection
More Efficient Way to Retrieve Firebase Data
How to Present a Uiviewcontroller from Skscene
iOS 13.1 Crash in Avaudio Player
How to Add Line Break for Uilabel
How to Change the Tint Color of the Clear Button on a Uitextfield
Hiding Uitabbar When Pushing a Uiview
Custom Interactive Transition Animation
How to Get a Cgpoint from a Tapped Location
Instantiate View Controller from Storyboard VS. Creating New Instance