gpt4 book ai didi

将在推文中预填充媒体的 iOS Twitter URL Scheme

转载 作者:可可西里 更新时间:2023-11-01 04:56:57 24 4
gpt4 key购买 nike

是否有一个 URL 方案,人们可​​以通过它打开 Twitter 应用程序,其中包含预先选择的给定媒体以及预先选择的消息一起发布?

我知道存在以下内容:

twitter://post?message=hello%20world

您还可以指定一个帐户:

twitter://post?message=hello%20world&account=helloworld

我希望能够使用用户相机胶卷中预先选择的图像或视频以及一条消息打开 Twitter。

最佳答案

this question 复制我的答案

这种事情以前是使用 Twitter Kit 完成的然而,推特dropped support对于 TwitterKit。

On October 31, 2018, we will no longer actively contribute to, or accept issues and pull requests on, the open sourced SDKs (iOS, Android, Unity) on GitHub. After this date we will also stop releasing the SDKs through Cocoapods, Carthage, and Bintray JCenter. Documentation and source code for all three SDKs on GitHub will remain available for consumption in an archived state.

此外,使用 Twitter 套件需要您拥有 Twitter 应用程序,并且用户授予您的 Twitter 应用程序访问其帐户信息的权限。

我能够使用 Branch.io 解决这个问题深层链接。

TLDR

  1. 将分支 SDK 添加到您的项目。
  2. 使用您要共享的图像的 url 和任何其他附加信息创建一个分支 url。
  3. 将“twitter”添加到您的应用 info.plist LSApplicationQueriesSchemes
  4. 使用引用 in this answer 的默认深层链接将该链接分享到 Twitter .示例:twitter://post?message=\(myBranchUrl)

您可以找到有关将 Branch 集成到您的 iOS 项目中的更多信息 here

您还可以查看下面的一些示例代码:

let buo = BranchUniversalObject.init(canonicalIdentifier: "content/12345")
buo.title = "My Content Title"
buo.contentDescription = "My Content Description"
buo.imageUrl = "https://lorempixel.com/400/400"
buo.publiclyIndex = true
buo.locallyIndex = true
buo.contentMetadata.customMetadata["key1"] = "value1"

let lp: BranchLinkProperties = BranchLinkProperties()
lp.channel = "facebook"
lp.feature = "sharing"
lp.campaign = "content 123 launch"
lp.stage = "new user"
lp.tags = ["one", "two", "three"]

lp.addControlParam("$desktop_url", withValue: "http://example.com/desktop")
lp.addControlParam("$ios_url", withValue: "http://example.com/ios")
lp.addControlParam("$ipad_url", withValue: "http://example.com/ios")
lp.addControlParam("$android_url", withValue: "http://example.com/android")
lp.addControlParam("$match_duration", withValue: "2000")

lp.addControlParam("custom_data", withValue: "yes")
lp.addControlParam("look_at", withValue: "this")
lp.addControlParam("nav_to", withValue: "over here")
lp.addControlParam("random", withValue: UUID.init().uuidString)

buo.getShortUrl(with: lp) { [weak self] (url, error) in
if let err = error {
// Handle Error
}

if let branchUrl = url, let urlScheme = URL(string: "twitter://post?message=\(branchUrl)") {
if UIApplication.shared.canOpenURL(urlScheme) {
UIApplication.shared.open(urlScheme, options: [:], completionHandler: nil)
} else {
// Twitter not installed
}
} else {
// Url Error
}
}

这将打开 Twitter 应用程序,如下所示: enter image description here

关于将在推文中预填充媒体的 iOS Twitter URL Scheme,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30249805/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com