首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在viber、Facebook信使和iOS应用程序的Instagram上共享文本?

如何在viber、Facebook信使和iOS应用程序的Instagram上共享文本?
EN

Stack Overflow用户
提问于 2015-06-04 05:46:57
回答 2查看 1.9K关注 0票数 3

如果有人知道如何与viber,Facebook,信使和instagram分享文本,请提供一些参考。

我已经尝试了对viber和Facebook-信使的canOpenURL方法,具体如下:

代码:

代码语言:javascript
复制
NSURL *fbURL = [NSURL URLWithString:@"fb-messenger://user-thread/USER-ID/"];
if ([[UIApplication sharedApplication] canOpenURL: fbURL]) {
    [[UIApplication sharedApplication] openURL: fbURL];
}
 NSString * urlViber = [NSString stringWithFormat:@"viber://send?  Text=text"];
NSURL * viberURL = [NSURL URLWithString:[urlViber stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL: viberURL]) {
    [[UIApplication sharedApplication] openURL: viberURL];
} else {
    Alert(@"Viber not installed.", @"Your device has no Viber installed.")
}

但是上面的代码只是简单地重定向到应用程序。它不会将文本传递给应用程序文本字段。

等待专家提供有用的指导。:)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-07-08 15:47:46

对于Viber:

代码语言:javascript
复制
[NSURL URLWithString:@"viber://forward?text=sdlmfkkanfj"]

对于Instagram:你必须与文本共享图像,只有你不能分享的文本。

代码语言:javascript
复制
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];

if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{       
    NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.igo"];
    NSString *urlString = [[NSString alloc] initWithFormat:@"file://%@", jpgPath];        
    NSURL *imageUrl = [[NSURL alloc] initWithString: urlString];

    self.docController = [self setupControllerWithURL:imageUrl usingDelegate:self];
    self.docController.UTI = @"com.instagram.exclusivegram";
    self.docController.annotation = [NSDictionary dictionaryWithObject:@"I_want_to_share_this_text" forKey:@"InstagramCaption"];

    [self.docController presentOpenInMenuFromRect: self.view.frame inView: self.view animated: YES ];
}
票数 0
EN

Stack Overflow用户

发布于 2015-06-04 06:52:51

试试下面的代码吧,如果你有什么问题,告诉我

代码语言:javascript
复制
NSString *string = [NSString stringWithFormat:@"%@  \n\n%@ %@ \n\n%@", @"Hey !" ,Str_Moretext,Str_caption,@""];

    NSURL *URL =[NSURL URLWithString:Str_ServerUrl];
     //UIImage *image=[UIImage imageNamed:@"ReferUsers.png"];

    @try {
         UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[string, URL] applicationActivities:nil];
        [self presentViewController:activityViewController animated:YES completion:^{
        }];
    } @catch (id theException) {
        NSLog(@"Received error %@",theException);

    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30635839

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档