从我的主要应用程序Swift开启另一个(我)的应用程序 [英] Opening another (mine) application from my main application Swift

查看:128
本文介绍了从我的主要应用程序Swift开启另一个(我)的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个应用程序,我想打开它们(如Facebook打开信使)。



经过一点搜索,我发现我必须知道我的应用程序的url方案,但我不知道如何声明它。在我的urlSchemes只是Facebook的方案。

  var url = NSURL(string:)
UIApplication.sharedApplication ).canOpenURL(url!)

我发现代码,据我所知,我必须把url我的urlScheme。



任何帮助?

解决方案

这是一个关于在您的应用程序中设置URL方案的好教程:



就是这样!您已经通过对URL方案 birdland:// 的简单支持配置了该应用程序。当然,您还可以使用自定义网址方案进行更多操作。要了解更多信息,请查看 Apple的文档



现在,要检查我们的注册URL方案是否正常,我们将前往Safari。按模拟器中的主页按钮(或按命令shift-H)到达主屏幕。打开Safari。



接下来,在Safari的地址栏中键入 birdland:// 。就像您可以使用http://网址一样,您要求Safari打开鸟巢计划。按Go。


I have two applications and i want to open them from each other (like facebook opens messenger).

After a little search i found that i have to know the url scheme of my app, but i don't know how can i declare it. In my urlSchemes are only facebook's schemes.

var url  = NSURL(string: "")  
UIApplication.sharedApplication().canOpenURL(url!)

I found that code and as i understand i have to put in the url my urlScheme.

Any help?

解决方案

Here is a good tutorial on setting up URL Schemes within you app: https://dev.twitter.com/cards/mobile/url-schemes

Incase this tutorial disappears, heres the info:

Configure our Xcode project

Go to Your Target > Info > URL Types

You need to define your custom URL type. Remember, you want to open the app via birdland://, so that will be your URL scheme. We also need to assign an unique identifier to the scheme. Apple recommends that you use reverse DNS notation to ensure that there are no name collisions on the platform, e.g com.mycompany.ios.

That’s it! You’ve configured the app with simple support for the URL scheme birdland://. There is, of course, much more that you can do with Custom URL Schemes. To find out more, check out Apple’s documentation.

Now, to check that our registered URL scheme works, we’ll head out to Safari. Press the "Home" button in the Simulator (or press command-shift-H) to reach the Home Screen. Open Safari.

Next, type birdland:// in the address bar of Safari. Just as you can with http:// URLs, you’re asking Safari to open the "birdland" scheme. Press Go.

这篇关于从我的主要应用程序Swift开启另一个(我)的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆