Incremental update
Unity3D
Outline
Access Guide
Check if MyApp is installed
Check if there is update
Start traffic-saving update/a>
FAQ
Android
Outline
Access Guide
Check if MyApp is installed
Check if there is update
Start traffic-saving update/a>
FAQ
Others
Data Structure
System Tools
Incremental update / Unity3D / Outline

Outline

MSDK and the MyApp team together provide the traffic-saving update function for games; users can download the difference update package to update the game package so as to saving traffic for them.

Access Guide

1 Access configuration

1)The game has complete configuration according to the description of msdk unity access configuration module

2) Ensure that the traffic-saving update configuration switch is checked. Refer to Access ConfigurationStep3 Configure information

2 Access workflow

Flow diagram of using MyApp traffic-saving update:

3 Refer to demos

For examples, refer to Assets\Example\MsdkDemo.cs script's ShowOthers() method.

Check if MyApp is installed

1 Summary

You can call WGCheckYYBInstalled() interface to check whether MyApp is installed and give the appropriate prompt; the check is not required, if your phone is not installed with MyApp, it will automatically download MyApp before update

2 Registration callback

None

3 Interface calling

1)Function description

You can call WGCheckYYBInstalled() interface to check whether MyApp is installed and give the appropriate prompt; the check is not required, if your phone is not installed with MyApp, it will automatically download MyApp before update

2)Interface declaration
int WGCheckYYBInstalled();
3)Parameter description

None

4)Return value

int type

0:MyApp has been installed
1:MyApp isn't installed
Other values indicate that a low version of MyApp is installed
5)Demo code
int ret = WGPlatform.Instance.WGCheckYYBInstalled();
switch (ret)
{
    case 0: // Game TODO  MyApp has been installed
        break;
    case 1: // Game TODO  MyApp isn't installed
        break;
    default: // Game TODO  A low version of MyApp is installed
        break;
}
6)Special description

None

7)Name interpretation

None

Check if there is update

1 Summary

Query if the current app has update

2 Registration callback

1)Function description

Check the game's update callback. The game needs to register the callback function for processing. It is suggested that the registration should be completed in the game's Awake function.

2)Interface declaration
public delegate void CheckUpdateDelegate(long newApkSize, string newFeature, 
        long patchSize, int status, string updateDownloadUrl, int updateMethod);
3)Parameter description
Parameter name Type Description
newApkSize long new apk package's file size
newFeature string new version description
patchSize long traffic-saving update package's file size
status int check result
TMSelfUpdateUpdateInfo.STATUS_OK : success
TMSelfUpdateUpdateInfo.STATUS_CHECKUPDATE_FAILURE : failure
TMSelfUpdateUpdateInfo.STATUS_CHECKUPDATE_RESPONSE_IS_NULL : response is null
updateDownloadUrl string download site
updateMethod int update mode
TMSelfUpdateUpdateInfo.UpdateMethod_NoUpdate : no update package
TMSelfUpdateUpdateInfo.UpdateMethod_Normal : full update package
  TMSelfUpdateUpdateInfo.UpdateMethod_ByPatch : incremental update package
4)Return value

None

5)Demo code
MsdkEvent.Instance.CheckUpdateEvent += (long newApkSize, string newFeature, 
        long patchSize, int status, string updateDownloadUrl, int updateMethod) => {
    if (status == TMSelfUpdateUpdateInfo.STATUS_OK) { //Query succeeds
        if (updateMethod == TMSelfUpdateUpdateInfo.UpdateMethod_NoUpdate)  {
            // Game TODO No update package
        } else if (updateMethod == TMSelfUpdateUpdateInfo.UpdateMethod_Normal) {
            // Game TODO Able to be updated in full
        } else if (updateMethod == TMSelfUpdateUpdateInfo.UpdateMethod_ByPatch) {
            // Game TODO Able to be incrementally updated
        }
    } else {
        // Game TODO Query fails
    }
};
6)Special description

None

7)Name interpretation

None

3 Interface calling

1)Function description

Call WGCheckNeedUpdate() interface to query if the current app has update

2)Interface declaration
void WGCheckNeedUpdate();
3)Parameter description

None

4)Return value

None. Call back through CheckUpdateEvent. As for the callback settings, please refer to the callback of check the game update

5)Demo code
WGPlatform.Instance.WGCheckNeedUpdate();
6)Special description

None

7)Term interpretation

None       

Start traffic-saving update

1 Summary

Call WGStartSaveUpdate() interface to start traffic-saving update

2 Registration callback

1 Register the game update package downloading progress callback

1)Function description

For the game update package download progress callback, the game needs to register the callback function for processing. It is suggested that the registration should be completed in the game's Awake function

2)Interface declaration
public delegate void DownloadAppProgressDelegate(long receiveDataLen, long totalDataLen);
3)Parameter description
Test name Type Description
receiveDataLen long downloaded data size
totalDataLen long total data size
4)Return value

None

5)Demo code
MsdkEvent.Instance.DownloadAppProgressEvent += (long receiveDataLen, long totalDataLen) => {
        long progress = receiveDataLen * 100 / totalDataLen;
        // Game TODO Being download. Already complete " + progress + "%";
};
6)Special description

None

7)Name interpretation

None

2Register the game update package downloade state change callback

1)Function description

For the game update package downloade state change callback, the game needs to register callback function for processing. It is suggested that the registration should be completed in the game's Awake function.

2)Interface declaration
public delegate void DownloadAppStateDelegate(int state, int errorCode, string errorMsg);
3)Parameter description
Test name Type Description
state int state:
TMAssistantDownloadTaskState.DownloadSDKTaskState_WAITING = 1;
TMAssistantDownloadTaskState.DownloadSDKTaskState_DOWNLOADING = 2;
TMAssistantDownloadTaskState.DownloadSDKTaskState_PAUSED = 3;
TMAssistantDownloadTaskState.DownloadSDKTaskState_SUCCEED = 4;
TMAssistantDownloadTaskState.DownloadSDKTaskState_FAILED = 5;
TMAssistantDownloadTaskState.DownloadSDKTaskState_DELETE = 6;
errorCode int error code
errorMsg string error information
4)Return value

None

5)Demo code
MsdkEvent.Instance.DownloadAppStateEvent += (int state, int errorCode, string errorMsg) => {
    if (state == TMAssistantDownloadTaskState.DownloadSDKTaskState_SUCCEED) {
        // Game TODO Download is completed
    } else {
        // Game TODO Download fails
    }
};
6)Special description

None

7)Name interpretation

None

3 Register MyApp downloading progress callback

1)Function description

MyApp downloading progress callback and the game needs to register callback function for processing. It is suggested that the registration should be completed in the game's Awake function.

2)Interface declaration
public delegate void DownloadYYBProgressDelegate(string url, long receiveDataLen, long totalDataLen);
3)Parameter description
Test name Type Description
url string download site
receiveDataLen long downloaded data size
totalDataLen long to-be-downloaded data size
4)Return value

None

5)Demo code
MsdkEvent.Instance.DownloadYYBProgressEvent += (string url, long receiveDataLen, long totalDataLen) => {
    Debug.Log("Download YYB url is " + url);
    long progress = receiveDataLen * 100 / totalDataLen;
    // Game TODO Being download. Already complete " + progress + "%";
};
6)Special description

None

7)Name interpretation

None

4 Register MyApp download state callback

1)Function description

For MyApp download state callback, the game needs to register callback function for processing. It is suggested that the registration should be completed in the game's Awake function.

2)Interface declaration
public delegate void DownloadYYBStateDelegate(string url, int state, int errorCode, string errorMsg);
3)Parameter description
Test name Type Description
url string download site
state int state:
TMSelfUpdateTaskState.SelfUpdateSDKTaskState_SUCCESS = 0;
TMSelfUpdateTaskState.SelfUpdateSDKTaskState_DOWNLOADING = 1;
TMSelfUpdateTaskState.SelfUpdateSDKTaskState_FAILURE = 2;
errorCode int error code
errorMsg string error information
4)Return value

None

5)Demo code
MsdkEvent.Instance.DownloadYYBStateEvent += (string url, int state, int errorCode, string errorMsg) => {
    Debug.Log("Download YYB url is " + url);
    if (state == TMSelfUpdateTaskState.SelfUpdateSDKTaskState_SUCCESS) {
        // Game TODO Download is completed
    } else {
        // Game TODO Download fails
    }
};
6)Special description

None

7)Name interpretation

None

3 Interface calling

1)Function description

Call WGStartSaveUpdate() interface to start saving traffic update. If your phone does not install MyApp, the interface can automatically download MyApp and call back it through DownloadYYBProgressEvent and DownloadYYBStateEvent interfaces, respectively. If your phone has installed MyApp, this interface will choose whether to launch the download of MyApp based on the parameters. The download progress and status changes will be called back to the game via DownloadAppProgressEvent and DownloadAppStateEvent.

2)Interface declaration
void WGStartSaveUpdate(bool isUseYYB);
3)Parameter description
Parameter name Type Description
isUseYYB bool whether or not to launch MyApp to update the game; if not, update will be completed directly in the game
4)Return value

No, the download progress and status changes will be called back to the game via DownloadAppProgressEvent and DownloadAppStateEvent

5)Demo code
WGPlatform.Instance.WGStartSaveUpdate(true);
6)Special description

If your phone does not install MyApp, the interface can automatically download MyApp and call back it through DownloadYYBProgressEvent and DownloadYYBStateEvent interfaces, respectively.

7)Term interpretation

None

FAQ