Skip to content

Instantly share code, notes, and snippets.

@naotokui
Last active December 13, 2015 22:29
Show Gist options
  • Save naotokui/4984986 to your computer and use it in GitHub Desktop.
Save naotokui/4984986 to your computer and use it in GitHub Desktop.
Sending image via Line.app Lineで画像データを送る方法
NSData *data = UIImageJPEGRepresentation([UIImage imageNamed:@"Flower.jpg"] , 0.5);
UIPasteboard* pasteboard = [UIPasteboard pasteboardWithName: LINE_PASTEBOARD create: YES];
[pasteboard setData: data forPasteboardType: (NSString *)kUTTypeJPEG];
// LINE
NSString *escapedStr = [LINE_PASTEBOARD stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSString *urlStr = [NSString stringWithFormat:@"line://msg/image/%@", escapedStr];
NSURL *sndUrl = [NSURL URLWithString:urlStr];
if ([[UIApplication sharedApplication] canOpenURL:sndUrl]) {
[[UIApplication sharedApplication] openURL:sndUrl];
} else {
[[[UIAlertView alloc] initWithTitle: @"" message:@"LINE not found."
delegate: nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil] show];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment