I have added an URL scheme to my application. The URL scheme is testapp://
. While I entered the text testapp://
in Safari and on hitting return, it launched my application.
Then I tested with testapp://placeid=12
. This is launching the TestApp in iPad but in iPhone, I am getting Cannot Open Page
and I am not able to test.
I could pass the placeid=12
as URL query. But what I would like to know is, why it is not opening in iPhone alone.
Any idea on this?
Note: Irrespective of device types, it seems to be iOS issue. This is the behaviour from iOS 6 and above.
Could it be that each device is running a different iOS version?
If so, please take into account some details depending on the version. For example, if you read the Advanced App Tricks , there is a section that may help you:
Handling URL Requests
An app that has its own custom URL scheme must be able to handle URLs passed to it. All URLs are passed to your app delegate, either at launch time or while your app is running or in the background. To handle incoming URLs, your delegate should implement the following methods:
- Use the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods to retrieve information about the URL and decide whether you want to open it. If either method returns NO, your app's URL handling code is not called.
- In iOS 4.2 and later, use the application:openURL:sourceApplication:annotation: method to open the file.
- In iOS 4.1 and earlier, use the application:handleOpenURL: method to open the file.
Hope this helps. Otherwise, I will really recommend you to stick to the standards . It would make your life easier :)
It is possibly not working because testapp://placeid=12 is not a valid URL. You will need a domain address there too, like testapp://localhost/query?placeid=12. It is possible the '=' character is causing the error.
I am not able to test it right now so let me know.
As mentioned in the question's note, it is iOS 6's Safari browser behaviour. We could not have "=" in the host of the URL while entering in Safari.
Instead, I solved this problem in the following manner.
Sent the URL in mail, and from Mail, if I click the URL, the app was launched. But the important point is, I had to parse the URL host to get the value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.