如何从URL方案中检索参数值 [英] How to retrieve parameter values from URL scheme
问题描述
我一直在使用iPad应用程序.我们已经为我们的应用设置了URL方案(例如myapp://?foo=1&bar=2
),以便当用户单击页面中的链接时,我们的应用将在iPad上打开.
I have been working on an iPad app. We have setup the URL scheme (e.g. myapp://?foo=1&bar=2
) for our app, so that when user clicks on link in a page, our app will open on iPad.
问题是如何从代码中的URL方案中检索参数值?
The problem is how to retrieve parameter values from URL scheme in the code?
有某种方法可以从应用程序入口点检索它,但是我不知道应用程序入口点在本机代码中的位置.我们已经通过Unity3D开发了该应用程序.那么有没有办法直接从Unity应用中检索参数值?
There would be some way to retrieve it from the application entry point, but I have no idea of where the entry point of the application is in native code. We have developed the app through Unity3D. So is there a way to retrieve parameter values directly from a Unity app ?
推荐答案
尝试一下,也许会对您有所帮助:
Try it like this, maybe it'll help you:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
NSLog(@"url recieved: %@", url);
NSLog(@"query string: %@", [url query]);
NSLog(@"host: %@", [url host]);
NSLog(@"url path: %@", [url path]);
NSDictionary *dict = [self parseQueryString:[url query]];
NSLog(@"query dict: %@", dict);
return YES;
}
这篇关于如何从URL方案中检索参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!