简体   繁体   English

如何共享URL方案链接到社交应用

[英]How to share an URL Scheme link to social app

I want to share an URL scheme link to social app so that when the user open social page on safari, when they click on the link, the URL scheme will call to the app I set. 我想共享一个指向社交应用程序的URL方案链接,以便当用户在野生动物园中打开社交页面时,当他们单击链接时,URL方案将调用我设置的应用程序。 But when I share, it only share the text. 但是当我共享时,它仅共享文本。 How to share the link instead of the text. 如何共享链接而不是文本。

在此处输入图片说明

Here is the code: 这是代码:

@IBAction func shareButtonAction(sender: AnyObject) {
        print("share")
        let myShare = "TestSafari://"
        let shareVC: UIActivityViewController = UIActivityViewController(activityItems: [myShare], applicationActivities: nil)
        self.presentViewController(shareVC, animated: true, completion: nil)
    }

You probably need to put a text first then the url, in that particular order. 您可能需要按照特定的顺序在文本后面加上url。 Try this: 尝试这个:

let string: String = ...
let URL: NSURL = ...
let shareVC = UIActivityViewController(activityItems: [string, URL])
let activityViewController = UIActivityViewController(
            activityItems: [image],
            applicationActivities: nil)
        activityViewController.excludedActivityTypes = [UIActivityTypeMessage,UIActivityTypeMail,UIActivityTypeCopyToPasteboard,UIActivityTypeAirDrop];
        presentViewController(activityViewController, animated: true, completion: nil)

use this code for Present ActivityViewController only change activityItems to your string. 将此代码用于Present ActivityViewController,仅将activityItems更改为您的字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM