Send URL with iMessage App

2019-07-11 02:11发布

问题:

I would like to send a link with my message to allow the user to open the app store to install the app or use a deep link to link into a certain piece of content in my app, similar to the Apple Music iMessage App. I am currently using:

var messagee:MSMessage = message.url = URL(string: "https://itunes.apple.com/us/app/reaction-timer-game/id572319874?ls=1&mt=8")
template.image = game1Image.image!
template.imageTitle = "Game 1"
template.imageSubtitle = "\(bestScore1[0])"

But when I tap on the the image the iMessage app opens instead of the URL. Is this possible and if so, how can I do this?

Should I be sending the URL with this:

let url = URL(string: "urlData")
    self.activeConversation?.insertAttachment(url!, withAlternateFilename: "URL", completionHandler: { (error) in
        if error != nil {
            print("Error")
        } else {
            print("Sent")
        }
    })

Thank you

回答1:

I don't think that's possible. If you try to open any URL or a URL scheme, it will open your main iOS app if you have one. In my case I wanted to display a web page so what I did is just use a UIWebView instead of opening Safari directly.

iMessage will already display your app link if the recipient doesn't have it installed. This helps app discoverability but you can't automatically open your app in the App Store.