05/15/2024 15:19:45

Line Channel Description

I. Developer Platform Configuration

I. Developer Platform Configuration

For Android system, after MSDK5.15 version (including 5.15), due to the limitation of the official Line-SDK, the MSDKLine module does not support Internal build method for packaging.

1.1 Register An Account

The game needs to go to LINE Platform to apply for App and configure the basic information.

1.2 Create a New Provider

1.3 Set Application Information

II. Android Project Configuration

II. Android Project Configuration

[info] Precautions about the Version
Since Line SDK is only compatible with miniSdkVersion>=17, problems may occur when it runs in Android 4.2 or earlier versions of Android systems. It is recommended that the game should set minSdkVersion> = 17.

minSdkVersion : 17 targetSdkVersion : 28

For Android system, after MSDK5.15 version (including 5.15), due to the limitation of the official Line-SDK, the MSDKLine module does not support Internal build method for packaging.

2.1 AndroidManifest.xml configuration

<uses-permission android:name="android.permission.INTERNET" />

2.2 Set Line under the android node in build.gradle file

android{                    
    compileOptions {                    
        sourceCompatibility JavaVersion.VERSION_1_8                    
        targetCompatibility JavaVersion.VERSION_1_8                    
    }                    
  }

[info]
As the LINE channel introduces the new features of Java8, it is needed to set the mandatory use of Java8 in the gradle file

2.3 MSDKConfig.ini file's settings

In the assets/MSDKConfig.ini file, add or modify the following settings:

[Line channel configuration]                    
LINE_CHANNEL_ID = {YOUR_LINE_CHANNEL_ID}    
LINE_UNIVERSAL_LINK_IOS = {YOUR_LINE_UNIVERSAL_LINK}                
LINE_CHECK_SDK_VERSION_ENABLE = 1

[info]

  1. Replace {YOUR_LINE_CHANNEL_ID} with the ChannelID applied by the game on the Line Developer platform
  2. Replace {YOUR_LINE_UNIVERSAL_LINK} with iOS Universal Link filled in by the game developer on the Line developer platform. If it is not enabled, leave it blank. Please refer to the "3.2 UniversalLink configuration" section
  3. LINE_CHECK_SDK_VERSION_ENABLE is used to verify the Android system version of the running device. If the system version of the device is earlier than Android 4.2, calling the Line channel's related interfaces will return "Not supported". This switch is ‘enabled by default’. If you want to turn it off, you can set it to 0, but you should evaluate the risk of doing so for your game.
  4. On the iOS platform, ChannelID before MSDK5.15 is obtained from LineSDKConfig in info.plist (refer to Section 3.1). But in MSDK5.15 and later versions, ChannelID in LineSDKConfig in info.plist is first read. If the 'Get' parameter is empty, then read the LINE_CHANNEL_ID configuration from MSDKConfig.ini.

2.4 Instructions about Java8 compatibility processing for each version of engine

1) Compatibility processing for Unity4.x and Unity5.x

Android system, before MSDK5.15, use the latest DexMerge tools to solve the problem that the number of the project's methods exceeds 65536.

For Android system, after MSDK5.15 version (including 5.15), due to the limitation of the official Line-SDK, the MSDKLine module does not support Internal build method for packaging.

2) Compatibility processing for Unity 2017-2019 and UnrealEngine

  1. Upgrade Android Gradle to 3.2 and configure it with Java8 support.
  2. Upgrade Unity Gradle to 4.6 or higher versions. (MSDK has verified: Unity 2017 can be upgraded up to 4.6 and others can be upgraded to 4.10 and above)
  3. BuildToolsVersion is upgraded to 28.0.1 or above.

3) Make UnrealEngine compatibility processing to support the integrated Line compilation (taking UE4.18 as an example)

Because the default configuration of UE4.18 on the constructor is not enough to support the integrated Line compilation, you need to modify it in the UE4_18 engine directory:

  1. gradle-wrapper.properties
     # File path: ${UE418_PATH}/Engine/Build/Android/Java/gradle/gradle/wrapper/gradle-wrapper.properties                    
     # Old configuration                    
     # distributionUrl=http\://android.oa.com/gradle/gradle-2.14.1-all.zip                     
     # New configuration                    
     distributionUrl=http\://android.oa.com/gradle/gradle-4.6-all.zip
    
  2. build.gradle
     // File path: ${UE418_PATH}/Engine/Build/Android/Java/gradle/build.gradle                    
     buildscript {                    
         ...                    
         dependencies {                    
             // Old configuration                    
             // classpath 'com.android.tools.build:gradle:2.2.2'                    
             // New configuration                    
             classpath 'com.android.tools.build:gradle:3.2.0'                    
             // NOTE: Do not place your application dependencies here; they belong                    
             // in the individual module build.gradle files                    
         }                    
         ...                    
     }
    
  3. build.gradle
     // File path: ${UE418_PATH}/Engine/Build/Android/Java/gradle/app/build.gradle                    
     // Some APIs are unavailable due to the upgrade of gradle, you need to make the following changes:                    
     ...                    
     def Set<String> outputFiles = []                    
     ...                    
     android {                    
         /** * Modify the name and path of the APK file in the release package * Studio3.0 * /                    
         android.applicationVariants.all { variant ->                    
             variant.outputs.all {                    
                 outputFileName = OUTPUT_PATH.substring(OUTPUT_PATH.lastIndexOf("/") + 1, OUTPUT_PATH.length())                    
                 outputFiles.add(outputFile)                    
             }                    
         }                    
     }                    
     afterEvaluate {                    
         assembleDebug.doLast {                    
             outputFiles.each { output ->                    
                 println("######### assembleDebug doLast: " + output)                    
                 String outputPath = OUTPUT_PATH.substring(0, OUTPUT_PATH.lastIndexOf("/"))                    
                 String filename = OUTPUT_PATH.substring(OUTPUT_PATH.lastIndexOf("/") + 1, OUTPUT_PATH.length())                    
                 println("######### assembleDebug doLast: " + outputPath + " filename: " + filename)                    
                 copy {                    
                     from output                    
                     into outputPath                    
                 }                    
             }                    
         }                    
         assembleRelease.doLast {                    
             outputFiles.each { output ->                    
                 println("######### assembleRelease doLast: " + output)                    
                 String outputPath = OUTPUT_PATH.substring(0, OUTPUT_PATH.lastIndexOf("/"))                    
                 String filename = OUTPUT_PATH.substring(OUTPUT_PATH.lastIndexOf("/") + 1, OUTPUT_PATH.length())                    
                 println("######### assembleRelease doLast: " + outputPath + " filename: " + filename)                    
                 copy {                    
                     from output                    
                     into outputPath                    
                 }                    
             }                    
         }                    
     }
    
III. iOS Project Configuration

III. iOS Project Configuration

3.1 Xcode project configuration file info.plist

Find or create the following nodes:

 <key>CFBundleURLTypes</key>                    
 <array>                    
        <dict>            
            <key>CFBundleTypeRole</key>        
            <string>Editor</string>        
            <key>CFBundleURLSchemes</key>        
            <array>        
                <string>line3rdp.{YOUR_BUNDLE_ID}</string>    
            </array>        
        </dict>            
    </array>                
 <key>LSApplicationQueriesSchemes</key>                    
 <array>                    
     <string>lineauth2</string>                    
     <string>line</string>                    
 </array>                    
 <key>LineSDKConfig</key>                    
      <dict>                
         <key>ChannelID</key>            
         <string>{YOUR_LINE_CHANNEL_ID}</string>            
      </dict>

Wherein, {YOUR_BUNDLE_ID} needs to be modified to the BundleIdentifier of the game project (it needs to be the same as the BundleIdentifier configured on the Line Developer platform), and {YOUR_LINE_CHANNEL_ID} needs to be modified to the ChannelID applied by the game
[info] If the ChannelID applied on the Line developer website is not configured in info.plist, an error, "ChannelID value cannot be found", will be reported when the user logs in the game, so the user can't log in the game.

On the iOS platform, ChannelID before MSDK5.15 is obtained from LineSDKConfig in info.plist. But in MSDK5.15 and later versions, ChannelID in LineSDKConfig in info.plist is first read. If the 'Get' parameter is empty, then read the LINE_CHANNEL_ID configuration from MSDKConfig.ini.

MSDKLine's UniversalLink supports versions after MSDK 5.15 (including 5.15), and iOS Line app version must be 8.16 or higher

Note: If the game is a version before 5.15, ignore the configuration

Universal Link is a mechanism introduced by Apple from iOS 9 to open up the jump between Web and App. When you open a link associated with an app in Safari or WebView, it will automatically jump to the app without losing parameters and content. Universal Link solves some problems of URL Scheme:

(1) When jump fails, a link will be opened directly in Safari/WebView; (2) Universal Link can be used to unify the routing between Web and Native; (3) No prompt box will pop up during jumping, so the user experience is better.

To use Universal Link, you need to associate the domain name with App. This association is two-way:

(1) Enable AppleID Associated Domains capability

According to Apple official documentation, contact the certificate management staffer to apply for enabling the AppleID Associated Domain capability, as shown in the following figure:

3

After the AppleID Associated Domains capability is enabled, please regenerate the signature description file.

(2) App authenticates the domain name: Set Associated Domains in the Signing&Capabilities option of Xcode, and add the domain name. Domains is always filled with applinks: +official website's domain name. Note that there is no need to add https: //. An example is as follows:

(3) The domain name authenticates App: Put a json file named apple-app-site-association in the root directory of the web server. Note that the suffix is ​​not required. The files describes which path will jump to which app. The content of the Json file is as follows:

{
    "applinks": {
        "apps": [],
        "details": [{
            "paths": ["/line-auth/*"],
            "appID": "YOUR_TEAM_ID.ios.bundle.id"
        }, 
        {
            "paths": ["/line-auth/*"],
            "appID": "JBS4AWYMFX.com.tencent.itop.example"
        },
        {
            "paths": ["/line-auth/*"],
            "appID": "JBS4AWYMFX.com.tencent.imsdk2"
        }]
    }
}

/line-auth/* in paths is the fixed configuration of Line channel

YOUR_TEAM_ID in appID: corresponds to TEAM_ID configuration on the Apple developer website

ios.bundle.id in appID: specifically fill in the corresponding 'Bundle ID' parameter of App on the Apple developer website

You can fill in several parameters here. For example, if the same App has other login channels which use UniversalLink, you can add the corresponding paths parameter of other channels; or if you have multiple apps sharing a json file called apple-app-site-association, then each appID in the above example corresponds to a specific app

(4) Fill in the corresponding 'Bundle ID' and 'Universal Link' configuration on the developer platform of Line Line developer console

image-20201126145311055

Fill in the correct iOS bundle ID and iOS Universal Link

Wherein, https://docs.itop.qq.com in the example is the domain name address of the web server where the json file apple-app-site-association is placed. The domain name address configuration here is different for each game. Carry the "/" at the end of /line-auth/ and don't miss it

(5) Configure MSDKConfig.ini

Add the configuration item LINE_UNIVERSAL_LINK_IOS in MSDKAppSetting.bundle/MSDKConfig.ini, and fill in the value of Universal Link configured on the developer platform of Line.

3.2.3 Warning

(1) The domain name must access Universal Link via HTTPS before it takes effect; (2) 'Apple-app-site-association' can only be placed in the root directory of the domain name, without redirection; (3) The system will go to the corresponding domain name to request 'apple-app-site-association file' when App is first installed and upgraded (the actual result is not reflected in Apple's official documentation). If Universal Link is unreachable and the configuration is normal , you can try to restart the smartphone or uninstall the App and install it again.

(1) App is started for the first time or it is started for the first time after the version is updated (the actual result is not reflected in Apple's official documentation); (2) App initiates a Get request to the domain name configured in the project to draw the 'apple-app-site-association' Json file; (3) App registers 'apple-app-site-association' to the system; (4) Any WebView initiates a redirect url; (5) If the universal link registered by apple-app-site-association is hit, open the app and trigger the Universal Link delegate; (6) If it is not hit, WebView continues to redirect to the url.

After 'apple-app-site-association' and App's Xcode project are configured, the entire Universal Link (UL) operation process is completely controlled by the iOS system. When the apple-app-site-association file is unavailable to access in Part 2 above, the newly installed users will not be able to jump to the App through UniversalLink unless it is uninstalled and reinstalled.

3.2.4 Implement iOS entry function

(1)Unity

Since GCloudCore now does not take effect for this entry method hook, it is needed to add the iOS lifecycle entry function to the UnityAppController class in the UnityAppController.mm file of Unity. Please check whether the entry function already exists before adding it. If not, add it manually (there is no need to add additional code in the function): Note: Do not add the lifecycle entry function in the subclasses of UnityAppController. Make sure that the entry function is in the same class as 'application:openURL:options:' and other system lifecycle functions

- (BOOL)application:(UIApplication *)application continueUserActivity:
(NSUserActivity *)userActivity restorationHandler:(void(^)
(NSArray<id<UIUserActivityRestoring>> *
__nullablerestorableObjects))restorationHandler {
    return YES;
}

(2)UnrealEngine

Implement a 'category' of iOSAppDelegate in iOS and place it in the MSDKCore/Source/MSDKCore/Private/iOS plugin. This solution uses iOS category for implementation, which has a risk of being replaced by other SDKs, so the game must verify whether UL takes effect.

Create a new IOSAppDelegate+MSDK.mm file with the following content:

# define WITH_MSDK 1

# if WITH_MSDK
# ifdef __APPLE__

# import <Foundation/Foundation.h>
# import "IOSAppDelegate.h"//UnrealEngine

# include "CoreDelegates.h"//UnrealEngine
# include "MSDKApplicationDelegate.h"

@interface IOSAppDelegate(MSDK)

@end

@implementation IOSAppDelegate(MSDK)
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
    NSLog(@"IOSAppDelegate(MSDK) continueUserActivity ");
    [[MSDKApplicationDelegate sharedInstance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
    return YES;
}
@end

# endif
# endif

MSDK V5.8.000 (GCloud V2.0.14) and above versions have used iOS category for implementation, which has a risk of being replaced by other SDKs, so the game must verify whether UL takes effect

Because Soda and DevOps corporate signature certificates currently do not have the Universal Link capability, game developers must use the development signature certificate for debugging games

3.2.5 How to verify

Verify that the apple-app-site-association file is reachable and valid

Enter the previously configured Universal Link link in the iOS memo, and click the link to see if it jumps directly to the game's app. If yes, this means that the apple-app-site-association file is reachable and valid. If it jumps to the Webview, this means the configuration is incorrect. https://docs.itop.qq.com in the figure below needs to be replaced with the game's own domain name address configured with the apple-app-site-association file.

image-20201126153940674

How ​to judge if the Universal Link configuration is correct

Scenario 1: In the normal login process, if a second confirmation box pops up when Line App jumps back to the game's App, this means that the jump must not be achievedthrough Universal Link.

image-20201126153135845

Scenario 2:

If you can log in the game when Universal Link (UL) is not configured but you cannot log in the game if UL is configured, and the login page jumps to the Webview after jumping to Line app and the Line app gives an error prompt, this means that the configuration has errors. In this case, you should check whether 'channelid', Universal Link and other configurations on the console are consistent with the corresponding configurations in MSDKConfig.ini. LINE_UNIVERSAL_LINK_IOS, LINE_CHANNEL_ID

image-20201126153536262

Scenario 3:

If the game's App jumps back from Line App in the login process, but there is the following keyword in the login's return log:

Callback from Line with Scheme with options

or

Callback from Line with Scheme with sourceApplication

this indicates that this jump is not achievedthrough Universal Link

Scenario 4:

If none of the above three scenarios occurs and the login page jumps back from Line App and the log exists:

Callback from Line with UniversalLink

this indicates that the current Universal Link must be correct

3.2.6 References

(1)Universal Links for Developers

(2)Enabling Universal Links

(3)Apple's official UL test tool

3.3 Unity engine adapts LineSDK's Swift and Objective-C's mixed compilation problem

MSDK5.11 (including 5.11) and later versions

Warning: If the game has integrated the MSDKLine channel before 5.11 and has processed the compatible Swift version through the script, this method can be ignored.

Find the XCodePostProcess file in Unity

Delete the comment and open the macro definition

image-20200818153409391

Versions before MSDK5.11

Because Line no longer maintains the Objective-C version of SDK, and subsequent SDKs all are of Swift versions, so all the current integrations are of the Swift version. Here involves the mixed compilation issue of Swift and Objective-C in iOS. In order to be compatible with the mixed compilation, Xcode needs to have a bridge to align the class names of the two languages. So the following operations are required.

Swift-LineSDK must be Xcode 10.3 and above, otherwise it is not supported

Precaution: There is currently no suitable UE4 to support Objective-C and Swift mixed compilation solution of iOS platform, so UE4 is not supported temporarily.

(1)Create a new file and select the Swift file type

(2)User-defined file name,, but make sure that the suffix is a .swift file, and then click "Create"

(3)Be sure to select "Create Bridging Header", otherwise Xcode will not create a bridging file.

(4)Make sure that there are two more files in the Xcode project, but it is not needed to modify the content of the files

If you encounter the following errors

Add the following in Library Search Paths

3.4 UnrealEngine engine adapts LineSDK's Swift and Objective-C's mixed compilation issues

In MSDK V5.7 and later versions, you need to deal with UnrealEngine's Swift and Objective-C mixed compilation issues

For details, please refer to UnrealEngine supports Swift and Objective-C mixed compilation configuration on iOS platform

3.5 Configure MSDKConfig.ini file

After adding the iOS plugins of MSDKGarena, find the MSDKAppSetting.bundle/MSDKConfig.ini file in the Xcode project and add or modify the following settings:

[Line channel configuration]                    
LINE_CHANNEL_ID = {YOUR_LINE_CHANNEL_ID}

[info] Replace {YOUR_LINE_CHANNEL_ID} with the ChannelID applied by the game on the Line Developer platform

3.6 Configuration of xx.projmods file of Unity XUPoter

When exporting a XCode project from Unity, you need to configure the xx.projmods file so that the exported XCode project can get the configuration shown in 3.1

{                    
    "group": "MSDKWeChat",                    
    "libs": [],                    
    "frameworks": [],                    
    "files": [],                    
    "folders": [],                    
    "excludes": [],                    
    "headerpaths":[],                    
    "build_settings": {},                    
    "system_capabilities": {},                    
    "Info.plist":{                    
        "LSApplicationQueriesSchemes":                    
        [                    
            "lineauth2",                    
            "line"                    
        ],                    
        "CFBundleURLTypes" :                    
        [                    
            {                    
                "CFBundleTypeRole":"Editor",                    
                "CFBundleURLSchemes":"line3rdp.{YOUR_BUNDLE_ID}"                    
            }                    
        ],                    
        "LineSDKConfig":{                    
            "ChannelID":"{YOUR_LINE_CHANNEL_ID}"                    
        }                    
    }                    
}

Wherein, {YOUR_BUNDLE_ID} needs to be modified to the BundleIdentifier of the game project (it needs to be the same as the BundleIdentifier configured on the Line Developer platform), and {YOUR_LINE_CHANNEL_ID} needs to be modified to the ChannelID applied by the game

3.7 Configuration of DefaultEngine.ini file of UnrealEngine

When UnrealEngine builds and exports a .ipa file, it is needed to configure the Config/DefaultEngine.ini file in the project's directory, or find the configuration items in the Unreal project. Find the corresponding locations of the following description items and modify or add them, so that the exported .ipa file can get the settings shown in 3.1

<key>CFBundleURLTypes</key>                    
<array>                    
    <dict>                    
        <key>CFBundleTypeRole</key>                    
        <string>Editor</string>                    
        <key>CFBundleURLSchemes</key>                    
        <array>                    
            <string>line3rdp.{YOUR_BUNDLE_ID}</string>                    
        </array>                    
    </dict>                    
</array>                    
<key>LSApplicationQueriesSchemes</key>                    
<array>                    
    <string>lineauth2</string>                    
    <string>line</string>                    
</array>                    
<key>LineSDKConfig</key>                    
<dict>                    
    <key>ChannelID</key>                    
    <string>{YOUR_LINE_CHANNEL_ID}</string>                    
</dict>

Wherein, {YOUR_BUNDLE_ID} needs to be modified to the BundleIdentifier of the game project (it needs to be the same as the BundleIdentifier configured on the Line Developer platform), and {YOUR_LINE_CHANNEL_ID} needs to be modified to the ChannelID applied by the game

IV. Function Description

IV. Function Description

4.1 Configure login and binding callbacks

1) Functional description

2) Interface declaration

C#
C++
// Logout callback, app wakeup callback					
					
public static event OnMSDKRetEventHandler<MSDKBaseRet> LoginBaseRetEvent;					
					
// Login callback, including login, bind, autologin, switchuser, etc.					
					
public static event OnMSDKRetEventHandler<MSDKLoginRet> LoginRetEvent;
class MSDKLoginObserver					
{					
public:					
					
    // Login callback, including login, bind, autologin, switchuser, etc.					
    virtual void OnLoginRetNotify(const MSDKLoginRet &loginRet) {};					
    					
    // Logout callback, app wakeup callback					
    virtual void OnBaseRetNotify(const MSDKBaseRet &baseRet) {};					
};

4.2 Login Function

1) Functional description

Line can log in the game without installing APP

  • iOS and Android can launch Line APP to log in the game if Line APP is installed. If Line APP is not installed, they will launch Web page to log in the game
  • No matter whether iOS launches APP for authorization or launches the Web page to log in an account through the Web page, it will launch the Web page to prompt whether to launch the game client after the account is logged in successfully. At this time, if you click "Reject", the game client will not be launched and the game client will not be able to receive any callback, either.
  • The authorized login of Line needs the grant of two permissions, that is, openid and profile. The former is to obtain the player's Line openid, and the latter is to obtain the player's Line AccessToken, which can be set through the 'permissions' field. If the 'permissions' field is left blank by the game, MSDK will use openid and profile permissions by default when logging into Line.

2) Interface declaration

C#
C++
public static void Login(string channel, string permissions = "", string subChannel = "", string extraJson = "")
public static void Login(const String &channel, const String &permissions, const String &subChannel, const String &extraJson)

3) Demo code

C#
C++
MSDKLogin.Login("Line");
std:string permissionList = "profile,openid";					
MSDKLogin::Login("Line", permissionList);

4.3 Message sending function

1) List of supported types

No. Function Required field Required App and login status
1 Send - text desc Need to download Line App
2 Send - image imagePath Need to download Line APP

2) Function description

The Line channel provides the function of sending messages, and only supports sending text or images. For the text you want to send, please assign a value to it in MSDKFriendReqInfo.desc. For the image you want to send, please transmit the image path (either local or network image path) in MSDKFriendReqInfo.imagePath.

[info] Precautions
The image can be a local image or a network image.



Copyright © 2024 MSDK.
All rights reserved.

results matching ""

    No results matching ""