OpenURL of Objective-C cannot open Japanese URL

Asked 2 months ago, Updated 2 months ago, 1 views

[UIApplication sharedApplication] openURL:@""
So, I can't open the URL that contains Japanese. Does anyone have any information?

The console contains
LaunchServices:ERROR:There is no registered handler for URL scheme(null)
appears.

For example, the link below cannot be opened.
[UIApplication sharedApplication] openURL:@"http://name.com";
[UIApplication sharedApplication] openURL:@"instagram://tag?name=grilled meat";

Each one will be opened from Safari, so I think it's a problem with the implementation.
However, if it is a URL that does not contain Japanese, you can open it with the above source code above.
Originally, I opened the URL including Japanese, but I feel like I can't open it after updating to Xcode7.

Please let me know if there is anything I can do.
Thank you for your cooperation.

ios objective-c

2022-09-30 14:04

1 Answers

Punycode encoding is required if the domain name contains Japanese.
Percent encoding is required if the query contains Japanese.

The corresponding libraries were published on GitHub.
Punycode-Cocoa makes it easy to respond.

When I tried it, I found out that

NSString*[email protected]"http://Name.com";
NSURL*url = NSURL URLWithString: name.encodedURLString;
[[UIAApplication sharedApplication] openURL:url];

started Safari in and the page was displayed correctly.
I opened it with exactly the same code even though the URL is https://www.google.co.jp/search?q=Japanese.
Therefore, I think instagram://tag?name=yakiniku can be done with this, too.


2022-09-30 14:04

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.