点击带有Bundle Identifier的按钮上的打开应用程序(无url方案)

时间:2019-04-16 21:57:58

标签: ios swift api

我目前正在开发一个应用,并且我试图添加一个按钮,当点击该按钮时,该按钮将打开手机上安装的另一个应用

我尝试为该应用程序寻找URL方案,但找不到。我唯一能找到的就是捆绑包ID。所以我想也许有一种方法可以使用包ID通过Swift中的私有API打开应用程序吗?如果有帮助,我的电话就越狱了。下面是我的代码

    @IBAction func openAppTapped(_ sender: Any) {
        UIApplication.shared.openURL(NSURL(string: "itms-apps://itunes.apple.com/us/app/apspace/id1413678891?mt=8")! as URL)      

    }

我在点击按钮后设法在appstore上运行了该应用程序,但是我想一种不使用url方案而是使用包ID和/或私有API直接打开该应用程序的方法。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

To open another app, you are either going to have to use some kind of extension provided by that app or figure out their URL scheme and reverse engineer it.

The first thing you could try is looking at the app's Info.plist and seeing if they have defined a URLScheme for their app. If not, and they haven't implemented an extension, then I think you're SOL.

If they did define it, try using it to open their app and see what happens, they might have some code that rejects or accepts a request to open their app based on the format of the URL after their scheme. If you can't figure it out with trial and error, you could use the fact that your phone is jailbroken to decompile their app and hunt down the URL parsing logic which is likely in their AppDelegate. From there you could try and build a URL that you can use to successfully open their app every time.