gpt4 book ai didi

ios - 打开带有预定义文本的 Facebook 应用程序以共享

转载 作者:行者123 更新时间:2023-11-29 01:41:35 33 4
gpt4 key购买 nike

请看这段代码:

 NSString *text = [NSString stringWithFormat:@"%@",
[@"Hello world!" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

NSString *post = [NSString stringWithFormat:@"fb://publish/profile/me?text=%@", text];

NSURL* url = [NSURL URLWithString:post];

if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}

通过这段代码,我想打开安装在设备上的 Facebook 应用程序,并在共享对话框中打开它,并将 text 字符串用作要共享的预定义文本。但不幸的是,它只是打开了我的时间线。我究竟做错了什么?甚至有可能吗?我找不到任何关于如何正确执行此操作的文档或教程。谢谢

最佳答案

使用 FacebookSDK 的框架有一个简单的方法。这只需要 2 分钟。

FBSDKCoreKit.framework
FBSDKShareKit.framework

如果您的设备中没有安装 facebook 应用程序,那么这将打开默认的网络浏览器。

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>

//在 vi​​ewdidload 或其他地方

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = @"Scare Prank";
content.contentDescription = @"Someone just got Scare Pranked with ♫";
content.contentURL = [NSURL URLWithString:soundUrl];
content.imageURL = [NSURL URLWithString:@“some icon url”];

FBSDKShareButton *button = [[FBSDKShareButton alloc] initWithFrame:CGRectMake(0, 0, 200, 43)];
button.center = self.center;
button.shareContent = content;
[self addSubview:button];

关于ios - 打开带有预定义文本的 Facebook 应用程序以共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32329859/

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