Line SDK access

Line is a similar to WeChat, QQ social networking tools, Wikipedia introduced as follows:

LINE (Japanese, Korean: lumira: and, he, Chinese official name: even I), is an instant messaging software and mobile applications, published in June 2011. Users can use the Internet to transfer text messages, pictures, animations, voice and video messages to other users (even voice calls) without additional fees. Since March 2016, LINE has registered more than 1 billion people worldwide, with some as many as 215 million active users

The company project needs to access the Line login and share function, share the pit when accessing, the SDK version used in this article is 3.2.1.

First of all, on the domestic AppStore, the search is less than Line’s APP. You need to log on to a foreign AppStore to download Line. Create a foreign area of AppleID, after the completion of the download, you can register Line account, you can use the domestic mobile phone number registration.

The first landing on the Line developer site (of course, the need to prepare VPN) requires App authentication on the client.

After you create the application, you can access it after you download SDK. Then, Xcode project can be set up in accordance with the official website iOS SDK access login address, which set the white list, if you need to access the sharing function, increase the line field, the effect is as follows:

< key> LSApplicationQueriesSchemes< /key> < array> < string> lineauth< /string> < string> line3rdp.$(APP_IDENTIFIER) < /string> < string> line< /string> < /array>

Get the user information interface as follows:

[[mAdapter getLineApiClient] getMyProfileWithResultBlock:^ (NSDictionary *aResult, NSError *aError) {if (aResult) {NSString *displayName aResult[@ = "displayName"]; NSString *mid aResult[@ = "Id"]; NSString *pictureUrl aResult[@ = "pictureUrl"]; NSString *statusMessage aResult[@ = "statusMessage"]; / / do something...} else {NSLog ("% @ @", aError); / / do something for error}]}..;

Among them, in the URL to get the avatar, add’/large’can get 200200 size picture, add’/small’ can get 5151 size pictures

The sharing of line is mainly carried out in the following manner


Can share text or pictures, share text < CONTENT TYPE> the value is text, share pictures < CONTENT TYPE> the value is image. < CONTENT TYPE> the value needs to be UTF-8 encoded

Share text:

- (BOOL) shareMessage: (NSString * message) {NSString *contentType = @ "text"; NSString *urlString = [NSString stringWithFormat:@ "line://msg/%@/%@" contentType, [urlString, message]; stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString:urlString]; if ([[UIApplication sharedApplication]canOpenURL:url]) {return [[UIApplication sharedApplication]openURL:url];}else{return NO;}}

Share pictures:

- (BOOL) sharePicture: (NSString * pictureUrl) {UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:pictureUrl]]; UIImage *image = [UIImage imageWithData:data]; pasteboard [setData:UIImageJPEGRepresentation (image, 0.9) forPasteboardType:@ "public.jpeg"]; NSString *contentType =@ "image"; NSString *contentKey = [ stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *urlString = [NSString stringWithFormat:@ line://msg/%@/%@ "contentType, NSURL, contentKey]; *url = [NSURL URLWithString:urlString]; if ([[UIApplication sharedApplication] canOpenURL:url]) {return [[UIApplication sharedApplicat Ion] openURL:url];}else{return NO;}

Share pictures when < CONTENT KEY> the value of the official website as follows:

Specify value in percent encoded (UTF-8) text. By principle, only the page title and page URL may be specified. sending from iPhone * When apps, please attach the image to the Pasteboard and set a PasteboardName in the following format: line://msg /image/ (PasteboardName) * When sending from Android devices, please specify a local image path that can be accessed by LINE in the following format: line://msg/image/ (localfilepath) information irrelevant to the * Specifying page is prohibited under the Guidelines.

Reference material

Developer’s official website address

IOS SDK share access address

UTI introduction