Skip to content

Instantly share code, notes, and snippets.

@osmszk
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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];
}
@koogawa
Copy link

koogawa commented Mar 23, 2014

            // LINEで送る
            UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
            [pasteboard setData:UIImagePNGRepresentation(capturedImage)
              forPasteboardType:@"public.png"];

            // pasteboardを使ってパスを生成
            NSString *lineUrlString = [NSString stringWithFormat:@"line://msg/image/%@", pasteboard.name];

            // URLスキームを使ってLINEを起動
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:lineUrlString]];

@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