如果有人知道如何与viber,Facebook,信使和instagram分享文本,请提供一些参考。
我已经尝试了对viber和Facebook-信使的canOpenURL方法,具体如下:
代码:
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.")
}但是上面的代码只是简单地重定向到应用程序。它不会将文本传递给应用程序文本字段。
等待专家提供有用的指导。:)
发布于 2015-07-08 15:47:46
对于Viber:
[NSURL URLWithString:@"viber://forward?text=sdlmfkkanfj"]对于Instagram:你必须与文本共享图像,只有你不能分享的文本。
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 ];
}发布于 2015-06-04 06:52:51
试试下面的代码吧,如果你有什么问题,告诉我
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);
}https://stackoverflow.com/questions/30635839
复制相似问题