gpt4 book ai didi

ios - 如何在 iOS 8 中不显示共享表直接启动事件?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:57:43 26 4
gpt4 key购买 nike

目前,我的应用程序可以选择使用 SLComposeViewController 在 Facebook 和 Twitter 上分享。

SLComposeViewController *fbComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbComposeViewController setInitialText:text_short];
[fbComposeViewController addURL:url];
[self.navigationController presentViewController:fbComposeViewController
animated:YES
completion:^{
NSLog(@"fb activity completed");
}];

我可以使用

分享到其他网站,如 Gmail、Whatsapp、消息和邮件
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[text, url]
applicationActivities:nil];

controller.excludedActivityTypes = @[UIActivityTypePostToWeibo,
UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo,
UIActivityTypePostToTencentWeibo,
UIActivityTypeAirDrop,
UIActivityTypePostToFacebook,
UIActivityTypePostToTwitter
];
[self presentViewController:controller animated:YES completion:nil];

然而,这会启动一个共享表,用户必须在其中选择他必须启动的应用程序。有没有办法通过指定事件名称直接启动共享对话框?例如,Uber 中的 Whatsapp、电子邮件和文本邀请。

最佳答案

例如,如果您想在 whatsapp 中分享

// this is your share content message
NSString * msg = @"ApplNSString YOUR MSG";


NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg];
NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

// this is identify if whatsapp is already install your device , if yes it open the whatsapp and share the content
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
} else {

// it shows the alert for no application found
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}

附加 reference

关于ios - 如何在 iOS 8 中不显示共享表直接启动事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32667760/

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