naotokui
2/19/2013 - 11:18 AM

Sending image via Line.app Lineで画像データを送る方法

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];
}