Skip to content

Instantly share code, notes, and snippets.

@osmszk
Last active August 29, 2015 13:57
Show Gist options
  • Save osmszk/9718995 to your computer and use it in GitHub Desktop.
Save osmszk/9718995 to your computer and use it in GitHub Desktop.
How to share image via LINE
- (void)shareImageViaLine:(UIImage *)image
{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
//[pasteboard setData:UIImageJPEGRepresentation(image, 1.0) forPasteboardType:@"public.jpeg"];
//→JPEGではできない模様 PNGならOK。
[pasteboard setData:UIImagePNGRepresentation(image) forPasteboardType:@"public.png"];
//PNGで!!!
NSString *urlString = [NSString stringWithFormat:@"line://msg/image/%@",pasteboard.name];
NSURL *url = [NSURL URLWithString:urlString];
[[UIApplication sharedApplication] openURL:url];
}
@osmszk
Copy link
Author

osmszk commented Mar 23, 2014

//LINEがインスコされてないとき用に、こうするとよさそう。(@t_okada さんより)
NSURL *url = [NSURL URLWithString:@"line://msg/image/"];
if (![[UIApplication sharedApplication] canOpenURL:url]){
lineButton.hidden = YES;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment