如何使用[[UIApplication sharedApplication] openURL:]打开其他应用程序?
我关注了 http://iosdevelopertips。 com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html 指令打开 app1(GlassButton) app2(字体测试)。
FontTest的open方法如下:
-(void)open {
BOOL res = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"glassbutton://"]];
if (res) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"glassbutton://"]];
}
}
“res”的值为“YES”,但调用openURL方法后没有任何反应。 “FontTest”的信息列表如下:
URL Schemes: glassbutton
URL identifier: com.yourcompany.glassbutton
我尝试通过“twitter://”和“fb://”成功打开twitter和facebook应用程序。但不知道为什么我打不开这个小应用程序。我不确定是否有任何事情/步骤错误或遗漏?我需要为 FontTest 处理 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
,如果是,如何处理?你能帮我一下吗?提前致谢!
I followed http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html instruction to open app1(GlassButton) within app2(FontTest).
The open method of FontTest as following:
-(void)open {
BOOL res = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"glassbutton://"]];
if (res) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"glassbutton://"]];
}
}
The value of "res" is "YES", but nothing happen after openURL method be called.
The info-list of "FontTest"as following:
URL Schemes: glassbutton
URL identifier: com.yourcompany.glassbutton
I tried to open twitter and facebook apps by "twitter://" and "fb://" successfully. But I do not know why I cannot open this small app. I'm not sure whether any thing/step wrong or missing? Need I handle - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
for FontTest, if yes, how to handle it? Could you please kindly help me? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要请求启动您的应用程序,请使用类似以下内容:
然后,在 glassbutton 应用程序中,您需要处理应用程序委托方法中的任何特殊行为:
请注意,在您打开的应用程序中,只会调用上述委托方法调用以下方法后:
进行相应处理,祝你好运。
To request the launch of your app use something like this:
Then, in the glassbutton app, you'll need to handle any special behavior within the app delegate method:
Note that within the app you are opening the above delegate method will only get called AFTER the following method is called:
Handle accordingly, good luck.