0

I'm running into an issue where I try and open an app from within another app but for some strange reason it keep opening the app thats already open, not the new app its supposed to open. I added the url scheme and and identifier to the plist and added the url scheme to the LSApplicationQueriesSchemes so it can be opened from within the app. I tried testing the url scheme in safari and for some strange reason it opens my app instead of the app its supposed to open. its like its on a loop, it keeps pointing to my app instead of the app its supposed to open.

This is how I'm opening it in code:

func openAppFromMenu(inAppURL: URL?, appStoreURL: URL?) {

    if inAppURL != nil {


        if let inApp = inAppURL {

            if UIApplication.shared.canOpenURL(inApp) {

                if #available(iOS 10.0, *) {
                    UIApplication.shared.open(inApp)
                }
                else {
                    UIApplication.shared.openURL(inApp)
                }
            }
            else {
                //redirect to safari because the user doesn't in app
                print("App not installed")
                self.appStoreURL = appStoreURL
                addAlert()

            }
        }
    } else {
        //redirect to safari because the user doesn't in app
        print("App not installed")
        self.appStoreURL = appStoreURL    
        addAlert()
    }
}
toddg
  • 2,863
  • 2
  • 18
  • 33
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
  • Sounds like you set up *your* app to use the custom URL scheme. – DonMag Sep 06 '17 at 16:12
  • 1. What's the point of the first `if` statement? 2. Are you sure you are passing the correct URL of the other app and not your own app? – rmaddy Sep 06 '17 at 16:14
  • Delete your app and try in safari. See if it opens the app supposed to open. – HMHero Sep 06 '17 at 16:14
  • i@HMHero it reads that the addrees is invalid after trying to open the app in safari – SwiftyJD Sep 06 '17 at 16:18
  • No one can help if you don't provide more details about the URLs and schemes involved. Double check your Info.plist and make sure you didn't setup your own app with the scheme of the app you are trying to launch. – rmaddy Sep 06 '17 at 16:32

0 Answers0