如何使用[[UIApplication sharedApplication] openURL:]打开其他应用程序?

发布于 2024-11-09 14:48:27 字数 944 浏览 0 评论 0原文

我关注了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪落纷纷 2024-11-16 14:48:27

要请求启动您的应用程序,请使用类似以下内容:

NSString *urlString= @"glassbutton://com.yourcompany.glassbutton";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

然后,在 glassbutton 应用程序中,您需要处理应用程序委托方法中的任何特殊行为:

 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {

    //your app specific code here for handling the launch

    return YES;
 }

请注意,在您打开的应用程序中,只会调用上述委托方法调用以下方法后:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

进行相应处理,祝你好运。

To request the launch of your app use something like this:

NSString *urlString= @"glassbutton://com.yourcompany.glassbutton";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

Then, in the glassbutton app, you'll need to handle any special behavior within the app delegate method:

 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {

    //your app specific code here for handling the launch

    return YES;
 }

Note that within the app you are opening the above delegate method will only get called AFTER the following method is called:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Handle accordingly, good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文