Outline
MSDK for Android offers a number of value-added capabilities, including notice system, inside webview, Pigeon push, data reporting, LBS and Crash analysis, in addition to providing login, friend relation chain, share, joining & binding groups and other capabilities. These value-added modules enable game developers to easily build extra capabilities for games and to be more focused on the user experience of the games themselves, thus bringing better games for players.
Access Guide
1 Preconditions
1) At first, you need to confirm that you have acquired MSDK Android version. If you have not acquired it, click the link below to download it.
2)It is needed to have installed the Java environment and configured the environment variables.
Configure system variables (please refer to):
JAVA_HOME : D:/Program Files/java/jdk1.6.0_25
Path : C:\Windows\system32;C:\Windows;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
CLASSPATH : .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
For more detailed steps, please search "Java environment variable configuration"
3) MSDK for Android requires JDK1.7 and above, and build-tools 22.0.1 and above.
4) The required minimum adaptative version is 8, and the compilation target version is 22
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="22" />
2 Import MSDK
MSDK's Android version package contains the demo project MSDKDemo
and the version dependency project MSDKLibrary
. Follow the steps below to quickly import MSDK.
1)Click on the eclipse menu : Project-> Properties-> Add...
2)Select MSDK's dependency package: MSDKLibrary
3 Add MSDK configurations
Open the MSDKDemo project and enter the "assets" directory, and then copy three files, msdkconfig.ini
, cert folder
and channel.ini
, to some place below the game project's "assets" directory
Note:
- The cert folder is not required for versions 3.2.6a through 3.2.18a.The channel.ini file is no longer needed since version 3.3.5a
- For 3.3.12a-3.3.15a versions, QQ OpenSDK FileProvider needs to make the following configuration: add the following configuration in AndroidManifest.xml:
<provider
android:authorities="com.example.wegame.QQSDKFileProvider"
android:name="android.support.v4.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
It is needed to add QQ file_paths.xml in the MSDKLibrary/res/xml directory, as follows:
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-files-path name="opensdk_external" path="Images/tmp"/>
<root-path name="opensdk_root" path=""/>
</paths>
Warning:
- You need to replace com.example.wegame in the above configuration with the application package name of the game itself, otherwise, this will cause the failure of obtaining images when sharing images and may lead to conflict with other apps. As fileProvider affects image sharing, it is recommended that the project team must check all images' sharing when accessing fileProvider to ensure that the image sharing function is available.
-
The content configured in file_paths.xml needs to match the image path and location passed in when the game calls the interface. MSDK carries some configurations by default. If the path configuration passed in by the game is not in the default configuration, the corresponding configuration needs to be supplemented.
-
Starting from version 3.3.16a, in order to facilitate games to access FileProvider, the FileProvider configurations of QQ and WeChat OpenSDK are processed together (Games which have accessed 3.3.12-3.3.15 need to modify related configuration). Add configuration items in AndroidManifest.xml as follows:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.wegame.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
It is needed to add file_paths.xml in the MSDKLibrary/res/xml directory, as follows:
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-files-path name="opensdk_external" path="Images/tmp"/>
<external-files-path name="sharedata" path="shareData/"/>
<external-files-path name="msdk_webview_share" path="MSDK/msdk_webview"/>
<root-path name="opensdk_root" path=""/>
</paths>
Warning:
- You need to replace com.example.wegame in the above configuration with the application package name of the game itself, otherwise, this will cause the failure of obtaining images when sharing images and may lead to conflict with other apps. As fileProvider affects image sharing, it is recommended that the project team must check all images' sharing when accessing fileProvider to ensure that the image sharing function is available.
- The content configured in file_paths.xml needs to match the image path and location passed in when the game calls the interface. MSDK carries some configurations by default. If the path configuration passed in by the game is not in the default configuration, the corresponding configuration needs to be supplemented.
4 Modify AndroidManifest.xml file
1) Copy MSDK-related permissions to some place below the "manifest" tag in the game's AndroidManifest.xml file
<!-- TODO Access to SDK Required permissions modules START -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- If you use the LBS function, you need to configure location permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- If you use the LBS function, you need to configure location permissions-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Login reporting requires the device name, which is gotten through the Bluetooth module -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- Optional permission: exception reporting system log and TPNS are also required -->
<uses-permission android:name="android.permission.READ_LOGS" />
<!-- Required permissions for TPNS Start-->
<!-- 【[Required] Required permissions for TPNS SDK VIP version -->
<!--Note: where com.example.wegame is modified to the package name of App-->
<permission
android:name="com.example.wegame.permission.XGPUSH_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.wegame.permission.XGPUSH_RECEIVE" />
<!-- 【Required】 Required permissions for TPNS SDK -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- The self-defined component permissions used inside Meizu push SDK don’t involve the user’s personal sensitive information or privacy compliance issues -->
<uses-permission android:name="com.meizu.flyme.permission.PUSH" />
<!-- [Optional] Required permissions for Tencent mobile push SDK -->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RESTART_PACKAGES" />
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" />
<uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" />
<!-- Required permissions for TPNS End-->
<!-- Permission configuration for access to TPNS vendor channel Start -->
<!--Note: where ${applicationId} is modified to the package name of App-->
<permission
android:name="${applicationId}.permission.MIPUSH_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.MIPUSH_RECEIVE" />
<uses-permission android:name="com.meizu.flyme.push.permission.RECEIVE" />
<permission android:name="${applicationId}.push.permission.MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="${applicationId}.push.permission.MESSAGE" />
<uses-permission android:name="com.meizu.c2dm.permission.RECEIVE" />
<permission android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.coloros.mcs.permission.RECIEVE_MCS_MESSAGE"/>
<uses-permission android:name="com.heytap.mcs.permission.RECIEVE_MCS_MESSAGE"/>
<!-- Permission configuration for access to TPNS vendor channel End -->
<!-- Read sdcard permission -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Adapt to Android 9.0 and use apache http -->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<!-- TODO SDK access to access payment requires a screen compatibility statement START -->
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true" />
<!-- TODO SDK access to access payment requires a screen compatibility statement END -->
<!-- TODO Access to SDK Required permissions modules END -->
2)Copy the relevant components of MSDK to some place under the "application" tag in the game's AndroidManifest.xml
<!-- 6.0 system permissions configuration activity; newly added in 2.18.0-->
<activity
android:name="com.tencent.msdk.PermissionActivity"
android:excludeFromRecents="true"
android:exported="true"
android:label="PermissionActivity"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:screenOrientation="behind"
<!-- 【Required】Please modify it into package name.diff -->
android:taskAffinity="com.example.wegame.diff" />
<activity
android:name="com.tencent.msdk.NameAuthActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="sensor"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<!-- TODO Access to SDK - QQ access configuration START -->
<activity
android:name="com.tencent.tauth.AuthActivity"
android:launchMode="singleTask"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- 【Required】Please modify it into Tencent Games' mobile QQ appid -->
<data android:scheme="tencent100703379" />
<!-- 100703379 needs to be changed into the game's appid -->
</intent-filter>
</activity>
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="behind"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<!-- QQSDKFileProvider configuration is required for 3.3.12-3.3.15, but not required since 3.3.16, where com.example.wegame is replaced with the package name of the game -->
<provider
android:authorities="com.example.wegame.QQSDKFileProvider"
android:name="android.support.v4.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
<!-- QQSDKFileProvider configuration is required for 3.3.12-3.3.15, but not required since 3.3.16, where com.example.wegame is replaced with the package name of the game -->
<!-- FileProvider configuration is required from 3.3.16, where com.example.wegame is replaced with the package name of the game -->
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.wegame.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
<!-- FileProvider configuration is required from 3.3.16, where com.example.wegame is replaced with the package name of the game -->
<!-- TODO Access to SD K- QQ access configuration END -->
<!-- TODO Access to SDK - WeChat access configuration START -->
<activity
<!-- 【Required】This should be changed into game package name.wxapi.WXEntryActivity -->
android:name="com.example.wegame.wxapi.WXEntryActivity"
android:excludeFromRecents="true"
android:exported="true"
android:label="WXEntryActivity"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
<!-- screenOrientation attribute, which has been removed in 3.3.0 and later versions -->
android:screenOrientation="portrait"
<!-- configChanges attribute, which has been created since 3.3.0 version -->
android:configChanges="orientation|screenSize|keyboardHidden"
<!-- 【Required】This should be changed into game package name.diff -->
android:taskAffinity="com.example.wegame.diff" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<!-- 【Required】This should be changed into the game's WeChat appid -->
<data android:scheme="wxcde873f99466f74a" />
<!-- The value of scheme should be changed into the game's WeChat appid -->
</intent-filter>
</activity>
<!-- TODO Access to SDK - WeChat access configuration END -->
<!-- TODO Access to SDK - WeChat scan code login configuration START -->
<activity
android:name="com.tencent.msdk.weixin.qrcode.WXQrCodeActivity"
android:excludeFromRecents="true"
android:exported="true"
android:label="WXQrCodeActivity"
android:launchMode="singleTask"
<!-- 【Required】 This should be changed into game package name.diff -->
android:taskAffinity="com.example.wegame.diff"
android:configChanges="orientation|screenSize|keyboardHidden"
android:theme="@android:style/Theme.Light.NoTitleBar"
android:screenOrientation="portrait">
<!-- The value of taskAffinity should be changed into: the game's package name.diff -->
</activity>
<!-- TODO Access to SDK - WeChat scan code login configuration END -->
<!-- TODO Notice configuration START -->
<activity
android:name="com.tencent.msdk.notice.AlertMsgActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="sensor"
android:theme="@style/NoticeAlertTheme" >
</activity>
<service android:name="com.tencent.msdk.notice.RollFloatService" >
</service>
<!-- TODO Notice configuration END -->
<!-- TODO Webview-related confiuration START -->
<activity
android:name="com.tencent.msdk.webview.JumpShareActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity>
<activity
android:name="com.tencent.msdk.webview.WebViewActivity"
android:process=":msdk_inner_webview"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize|keyboardHidden|navigation|fontScale|locale"
android:screenOrientation="unspecified"
android:theme="@android:style/Theme.NoTitleBar"
android:windowSoftInputMode="stateHidden|adjustResize" >
<meta-data android:name="titlebar_hideable" android:value="false"/>
<meta-data android:name="toolbar_portrait_hideable" android:value="false"/>
<meta-data android:name="toolbar_landscape_hideable" android:value="false"/>
</activity>
<!-- TODO Webview-related confiuration END -->
<!-- TODO MyApp traffic-saving update related confiuration START -->
<service
android:name="com.tencent.tmdownloader.TMAssistantDownloadService"
android:exported="false"
android:process=":TMAssistantDownloadSDKService" >
</service>
<!-- TODO MyApp traffic-saving update END -->
<!-- msdk httpdns network listening; this configuration is deprecated -->
<receiver
android:name="com.tencent.special.httpdns.Cache$ConnectReceiver"
android:label="NetworkConnection" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<!-- Component configuration for TPNS START -->
<!-- If the access point is the Shanghai cluster, it is needed to add additional configurations START -->
<!-- For TPNS 1.1.6.3 and previous versions including XG_GUID_SERVER, XG_STAT_SERVER and XG_LOG_SERVER, the configuration takes effect; for versions later than 1.1.6.3, such as XG_SERVER_SUFFIX, the configuration also takes effect. It is recommended to add the configuration to prevent incompatibility issues in subsequent upgrades. XG_GUID_SERVER, XG_STAT_SERVER and XG_LOG_SERVER need to carry https header, but XG_SERVER_SUFFIX does not need to carry https header-->
<meta-data
android:name="XG_GUID_SERVER"
android:value="https://guid.tpns.sh.tencent.com/guid/api/GetGuidAndMqttServer" />
<meta-data
android:name="XG_STAT_SERVER"
android:value="https://stat.tpns.sh.tencent.com/log/statistics/push" />
<meta-data
android:name="XG_LOG_SERVER"
android:value="https://log.tpns.sh.tencent.com/v3/mobile/log/upload" />
<meta-data
android:name="XG_SERVER_SUFFIX"
android:value="tpns.sh.tencent.com" />
<!-- If the access point is the Shanghai cluster, it is needed to add additional configurations END -->
<!-- Used to delay the start of TPNS service. The service is not started until registration, so as to meet compliance-->
<meta-data
android:name="XG_SERVICE_PULL_UP_OFF"
android:value="true" />
<!-- [Required] 'old_access_id' is filled in with 'AccessId' of the free version of TPNS before upgrade. If you don't know this, you can query it at Feiying system's SDK parameters section -->
<meta-data
android:name="XG_OLD_ACCESS_ID"
android:value="xxx" />
<!-- [Required] Please modify it to the 'AccessId' of APP. The 'AccessId' prefixes of different clusters are different. The Shanghai cluster starts with 158, and the Guangzhou cluster starts with 150. The prefix generated after registration shall prevail, with no spaces in between -->
<meta-data
android:name="XG_V2_ACCESS_ID"
android:value="xxx" />
<!-- [Required] Please modify it to the 'AccessKey' of APP, which is a 12-digit character string starting with "A", with no spaces in between -->
<meta-data
android:name="XG_V2_ACCESS_KEY"
android:value="xxx" />
<!-- [Required] TPNS default notification -->
<!-- [Warning] XGPushActivity configuration has been obsolete since version 3.3.16 -->
<activity
android:name="com.tencent.android.tpush.XGPushActivity">
<intent-filter>
<action android:name="android.intent.action" />
</intent-filter>
</activity>
<!-- [Warning] XGPushActivity configuration has been obsolete since version 3.3.16 -->
<!-- [Warning] TpnsActivity configuration begins to be added in version 3.3.16, where 'host' is replaced with "the app's package name" -->
<activity android:name="com.tencent.android.tpush.TpnsActivity"
android:exported="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<data
android:scheme="tpns"
android:host="com.example.wegame"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- [Warning] TpnsActivity configuration begins to be added in version 3.3.16, where 'host' is replaced with "the app's package name" -->
<!-- [Required] TPNS receiver -->
<receiver
android:name="com.tencent.android.tpush.XGPushReceiver"
android:process=":xg_vip_service">
<intent-filter android:priority="0x7fffffff">
<!-- [Required] Internal broadcast of TPNS SDK -->
<action android:name="com.tencent.android.xg.vip.action.SDK" />
<action android:name="com.tencent.android.xg.vip.action.INTERNAL_PUSH_MESSAGE" />
<action android:name="com.tencent.android.xg.vip.action.ACTION_SDK_KEEPALIVE" />
<!-- [Optional] System broadcast: network switch -->
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<!-- [Optional] System broadcast: open screen -->
<action android:name="android.intent.action.USER_PRESENT" />
<!-- [Optional] Some commonly used system broadcasts can enhance the resurrection chance of Tencent Mobile Push TPNS service. Please choose them according to your needs. Of course, you can also add some broadcasts defined by App to start the service -->
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
<!-- [Required] TPNS service -->
<!-- The `persistent` attribute of the XGVipPushService node has been removed since version 3.3.281 -->
<service
android:name="com.tencent.android.tpush.service.XGVipPushService"
android:process=":xg_vip_service"></service>
<service android:name="com.tencent.android.tpush.rpc.XGRemoteService">
<intent-filter>
<!-- [Required] Please modify it to the current APP's package name.XGVIP_PUSH_ACTION -->
<action android:name="com.example.wegame.XGVIP_PUSH_ACTION" />
</intent-filter>
</service>
<!-- [Required] [Warning] 'authorities' is modified to package name.XGVIP_PUSH_AUTH -->
<provider
android:name="com.tencent.android.tpush.XGPushProvider"
android:authorities="com.example.wegame.XGVIP_PUSH_AUTH" />
<!-- If you need to turn off the joint survival function applied together with TPNS, you can configure your app not to be launched by other apps, and you can add the following configuration. If you don't need it, you can ignore the following configuration. Where, 'authorities' is modified to package name.xxx.XGVIP_PUSH_AUTH, where xxx is any user-defined name: -->
<!-- [Warning] This configuration is the same as the previous configuration node. You can choose one of the two. Here, for ease of presentation, they are written separately -->
<provider
android:name="com.tencent.android.tpush.XGPushProvider"
tools:replace="android:authorities"
android:authorities="com.example.wegame.xxx.XGVIP_PUSH_AUTH"
android:exported="false"
android:enabled="false"/>
<!-- [Required] [Warning] 'authorities' is modified to package name.TPUSH_PROVIDER -->
<provider
android:name="com.tencent.android.tpush.SettingsContentProvider"
android:authorities="com.example.wegame.TPUSH_PROVIDER" />
<!-- [Optional] Used to enhance the survival capability -->
<!-- [Warning] 'authorities' is changed to package name.AUTH_XGPUSH_KEEPALIVE -->
<provider
android:name="com.tencent.android.tpush.XGVipPushKAProvider"
android:authorities="com.example.wegame.AUTH_XGPUSH_KEEPALIVE"
android:exported="true" />
<!-- MQTT START-->
<service android:exported="false"
android:process=":xg_vip_service"
<!-- [Warning] 'name' has been changed to com.tencent.tpns.mqttchannel.services.MqttService since version 3.3.16-->
android:name="com.tencent.bigdata.mqttchannel.services.MqttService" />
<!-- [Warning] 'name' has been changed to com.tencent.tpns.mqttchannel.services.MqttService since version 3.3.16-->
<!--[Warning] 'authorities' is changed to package name.XG_SETTINGS_PROVIDER -->
<provider
android:exported="false"
<!-- [Warning] 'name' has been changed to com.tencent.tpns.baseapi.base.SettingsContentProvider since version 3.3.16-->
android:name="com.tencent.bigdata.baseapi.base.SettingsContentProvider"
<!-- [Warning] 'name' has been changed to com.tencent.tpns.baseapi.base.SettingsContentProvider since version 3.3.16-->
android:authorities="com.example.wegame.XG_SETTINGS_PROVIDER" />
<!-- MQTT END-->
<!-- Component configuration for TPNS END -->
The following is the relevant configuration of XG vendor channel component, where ${HW_APPID}is replaced with the HW_APPID applied for by yourself, and ${applicationId}is replaced by your own package name
<!-- TPNS vendor channel component's configuration Start -->
<meta-data
android:name="com.huawei.hms.client.appid"
android:value="${HW_APPID}" >
</meta-data>
<!-- Starting from version 3.3.18, there is no need to declare BridgeActivity and UpdateProvider, since they have been declared in HWPushSDK -->
<activity
android:name="com.huawei.hms.activity.BridgeActivity"
android:configChanges="orientation|locale|screenSize|layoutDirection|fontScale"
android:excludeFromRecents="true"
android:exported="false"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent" >
<meta-data
android:name="hwc-theme"
android:value="androidhwext:style/Theme.Emui.Translucent" />
</activity>
<provider
android:name="com.huawei.hms.update.provider.UpdateProvider"
android:authorities="${applicationId}.hms.update.provider"
android:exported="false"
android:grantUriPermissions="true" >
</provider>
<!-- Starting from version 3.3.18, there is no need to declare BridgeActivity and UpdateProvider, since they have been declared in HWPushSDK -->
<!-- PushEventReceiver and HWPushMessageReceiver have been removed in version 3.3.18 -->
<receiver android:name="com.huawei.hms.support.api.push.PushEventReceiver" >
<intent-filter>
<!-- Receive the notification message from the channel, and is compatible with the old version of PUSH -->
<action android:name="com.huawei.intent.action.PUSH" />
</intent-filter>
</receiver>
<receiver android:name="com.tencent.android.hwpush.HWPushMessageReceiver" >
<intent-filter>
<!-- Required, used to receive TOKEN -->
<action android:name="com.huawei.android.push.intent.REGISTRATION" />
<!-- Required, used to receive messages -->
<action android:name="com.huawei.android.push.intent.RECEIVE" />
<!-- Optional, used to trigger onEvent callback after clicking the notification bar or the button on the notification bar -->
<action android:name="com.huawei.android.push.intent.CLICK" />
<!-- Optional, check whether the PUSH channel is connected; if you don't check it, you don't need it -->
<action android:name="com.huawei.intent.action.PUSH_STATE" />
</intent-filter>
</receiver>
<!-- PushEventReceiver and HWPushMessageReceiver have been removed in version 3.3.18 -->
<!--XiaoMi-->
<service
android:name="com.xiaomi.push.service.XMPushService"
android:enabled="true"
android:process=":pushservice" />
<service
android:name="com.xiaomi.push.service.XMJobService"
android:enabled="true"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"
android:process=":pushservice" />
<!-- Note: This service must be added after 3.0.1 version (including 3.0.1 version) -->
<service
android:name="com.xiaomi.mipush.sdk.PushMessageHandler"
android:enabled="true"
android:exported="true" />
<service
android:name="com.xiaomi.mipush.sdk.MessageHandleService"
android:enabled="true" />
<!-- Note: This service must be added after 2.2.5 version (including 2.2.5 version) -->
<!-- The intent-filter corresponding to NetworkStatusReceiver needs to be deleted -->
<receiver
android:name="com.xiaomi.push.service.receivers.NetworkStatusReceiver"
android:exported="true" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver
android:name="com.xiaomi.push.service.receivers.PingReceiver"
android:exported="false"
android:process=":pushservice" >
<intent-filter>
<action android:name="com.xiaomi.push.PING_TIMER" />
</intent-filter>
</receiver>
<receiver
android:exported="true"
android:name="com.tencent.android.mipush.XMPushMessageReceiver">
<intent-filter>
<action android:name="com.xiaomi.mipush.RECEIVE_MESSAGE" />
</intent-filter>
<intent-filter>
<action android:name="com.xiaomi.mipush.MESSAGE_ARRIVED" />
</intent-filter>
<intent-filter>
<action android:name="com.xiaomi.mipush.ERROR" />
</intent-filter>
</receiver>
<!--MeiZu-->
<service
android:name="com.meizu.cloud.pushsdk.NotificationService"
android:exported="true"/>
<!--Starting from version 3.3.256a, Meizu channel has begun to add the `MzPushSystemReceiver` node and remove the `com.meizu.cloud.pushsdk.SystemReceiver` node-->
<receiver
android:name="com.meizu.cloud.pushsdk.MzPushSystemReceiver"
android:exported="false"
android:permission="com.meizu.flyme.permission.PUSH">
<intent-filter>
<action android:name="com.meizu.flyme.push.intent.PUSH_SYSTEM" />
</intent-filter>
</receiver>
<receiver
android:name="com.tencent.android.mzpush.MZPushMessageReceiver"
android:exported="true">
<intent-filter>
<!-- Receive PUSH messages -->
<action android:name="com.meizu.flyme.push.intent.MESSAGE" />
<!-- Receive 'register' messages-->
<action android:name="com.meizu.flyme.push.intent.REGISTER.FEEDBACK"/>
<!-- Receive 'unregister' messages-->
<action android:name="com.meizu.flyme.push.intent.UNREGISTER.FEEDBACK"/>
<action android:name="com.meizu.c2dm.intent.REGISTRATION" />
<action android:name="com.meizu.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}"></category>
</intent-filter>
</receiver>
<!--OPPO-->
<!--OPPO channel PushService and AppPushService have been removed since version 3.3.281-->
<service
android:name="com.heytap.mcssdk.PushService"
android:permission="com.coloros.mcs.permission.SEND_MCS_MESSAGE">
<intent-filter>
<action android:name="com.coloros.mcs.action.RECEIVE_MCS_MESSAGE"/>
</intent-filter>
</service>
<service
android:name="com.heytap.mcssdk.AppPushService"
android:permission="com.heytap.mcs.permission.SEND_MCS_MESSAGE">
<intent-filter>
<action android:name="com.heytap.mcs.action.RECEIVE_MCS_MESSAGE"/>
</intent-filter>
</service>
<!--OPPO channel PushService and AppPushService have been removed since version 3.3.281-->
<!--OPPO channel has added CompatibleDataMessageCallbackService and DataMessageCallbackService configurations in version 3.3.281-->
<service
android:name="com.heytap.msp.push.service.CompatibleDataMessageCallbackService"
android:permission="com.coloros.mcs.permission.SEND_MCS_MESSAGE"
android:exported="true">
<intent-filter>
<action android:name="com.coloros.mcs.action.RECEIVE_MCS_MESSAGE"/>
</intent-filter>
</service>
<service
android:name="com.heytap.msp.push.service.DataMessageCallbackService"
android:permission="com.heytap.mcs.permission.SEND_PUSH_MESSAGE"
android:exported="true">
<intent-filter>
<action android:name="com.heytap.mcs.action.RECEIVE_MCS_MESSAGE"/>
<action android:name="com.heytap.msp.push.RECEIVE_MCS_MESSAGE"/>
</intent-filter>
</service>
<!--OPPO channel has added CompatibleDataMessageCallbackService and DataMessageCallbackService configurations in version 3.3.281-->
<!-- TPNS vendor channel component's configuration End -->
3) Modify the launchmode of the game's main Activity into singleTask The example is configured as follows:
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="sensor"
android:launchMode="singleTask"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
...
</activity>
5 Edit the game's configuration information
Open msdkconfig.ini file in the game project's "assets" directory to edit MSDK's configuration information
Description of MSDK configuration items
Field | Platform | Description |
---|---|---|
MSDK_ENV | Android | MSDK environment selection; MSDK can choose the test environment in case of joint debugging; after its official release, it must choose the formal environment |
WXTOKEN_REFRESH | Android | MSDK WeChat's switch for automatically refreshing the token; for more details, please refer to login module |
PUSH | Android | Pigeon push function switch |
needNotice | Android | MSDK notice function switch |
noticeTime | Android | MSDK notice system's notice data update time(notice data requested when going online), in minutes (minimum 5 minutes) |
MSDK_REAL_NAME_AUTH_SWITCH | Android | real-name authentication configuration(3.2.14 and higher versions must configure it as 1); 0: use MSDK real-name authentication UI, and return back to the login page after authentication; 1: use MSDK real-name authentication UI, and login to the game after authentication; 2: use the game-defined authentication UI, and call back to the game after authentication; |
BETA | Android | MyApp number-grabbing function switch |
STAT_LOG | Android | Beacon, Bugly and QQ OpenSDK log switch. When it is set to true, detailed logs will be printed. When an app is officially released, it is needed to set the switch to false; 3.3.271 version starts to support QQ OpenSDK |
CLOSE_BUGLY_REPORT | Android | Close Bugly reporting switch; the switch is set to true, meaning to turn off the Crash reporting function |
SAVE_UPDATE | Android | MyApp traffic-saving download and update function's switch |
GRAY_TEST_SWITCH | Android | white list limit switch; if you want to reserve number-grabbing, you need to apply for it from the collaboration & planning group |
localLog | Android | This configuration has been removed in 3.x versions SDKLog switch 0: Don't print; 1: Print logcat; 2: Print to local file; 3: Print logcat and local file at the same time; the printed local file is saved in: versions older than 2.15.1: SDCard/MSDK/msdk.log 2.15.1 and above versions:/sdcard/Android/data/the game's package name/files/MSDKLog.log.0 |
SCOPE | Android | Extended WeChat scope field; multiple scopes are separated with ", "; version 2.18.0 starts to support this |
V2SIGNING_ENABLED | Android | V2 signature switch; packages enabling V2 signature must open this switch (failure to open the switch can lead to the channel number read error); if it is null, it is “OFF” by default |
V3SIGNING_ENABLED | Android | V3 signature switch; this switch must be turned on for packages which use V3 signature (otherwise, a channel number reading error will occur); 'true' means 'enabled'; if it is not filled in, the switch is turned off by default; Version 3.3.15 starts to support it |
IPV6_SUPPORT | Android | Whether or not to support IPV6? Set the value as true, meaning to support IPV6; false means not to support it; 3.3.0 version starts to support the field |
BEACON_SENSOR_ENABLE | Android | Whether to enable BeaconID acquisition; true means "enable", false means "disable"; it is supported since version 3.3.9, and enabled by default since version 3.3.18; this configuration has been removed since version 3.3.21 |
BEACON_CC_ENABLE | Android | Whether to enable anti-cheat,not turned on by default;'true' means 'enabled', and 'false' means 'disabled'; Version 3.3.9 starts to support it |
BEACON_PAGE_PATH_ENABLE | Android | Whether to open page tracking,not turned on by default;'true' means 'enabled', and 'false' means 'disabled'; Version 3.3.9 starts to support it |
XG_OTHER_PUSH_ENABLE | Android | Whether to enable Tencent mobile push vendor channel, which is disabled by default; 'true' means 'enabled', and 'false' means 'disabled'; Version 3.3.11 starts to support it |
XG_OTHER_PUSH_XIAOMI_APPID | Android | Fill in the appId of the Xiaomi channel; version 3.3.11 starts to support it |
XG_OTHER_PUSH_XIAOMI_APPKEY | Android | Fill in the appKey of the Xiaomi channel; version 3.3.11 starts to support it |
XG_OTHER_PUSH_MEIZU_APPID | Android | Fill in the appId of the Meizu channel; version 3.3.11 starts to support it |
XG_OTHER_PUSH_MEIZU_APPKEY | Android | Fill in the appKey of the Meizu channel; version 3.3.11 starts to support it |
XG_OTHER_PUSH_OPPO_APPID | Android | Fill in the appKey of the OPPO channel; version 3.3.11 starts to support it |
XG_OTHER_PUSH_OPPO_APPSECRET | Android | Fill in the appSecret of the OPPO channel; version 3.3.11 starts to support it |
MSDK_WEBVIEW_LOADING_BACKGROUND_COLOR | Android | A switch used to load the loading page when opening Webview; the loading of the loading page is not enabled if the field is not configured or set to ""; if the field is configured, the loading page that carries the background color will be enabled and it is needed to fill in a hexadecimal color value in a format of not including transparency, such as: #000000; version 3.3.12 begins to support this function |
XG_PULL_UP_OTHER_APP_ENABLE | Android | A switch for Tencent Mobile Push's joint survival capability; 'true' means 'enabled', and 'false' means 'disabled'; it is disabled by default to prevent its own app from waking up other apps; Version 3.3.13 starts to support it |
MSDK_CENTER_CONTROL_WEBVIEW_LOADING_BACKGROUND_COLOR | Android | A switch for the loading page's background color when opening the central control Webview; if the switch is not configured, the color is defaulted as: #010C0F; version 3.3.16 starts to support it |
CLOSE_BEACON_REPORT | Android | Beacon reporting switch, which should be set to false by default; if it is set to true, this means to turn off the Beacon reporting function; if it is not configured, it will be enabled by default; Version 3.3.17 starts to support it |
CLOSE_HTTPDNS | Android | HttpDns switch, which should be set to false by default; if it is set to true, this means to turn off the HttpDns function; if it is not configured, it will be enabled by default; Version 3.3.17 starts to support it |
BUGLY_REPORT_URL_ANDROID | Android | Bugly's self-defined Server Url configuration, which is used for the migration from Bugly to CrashSight. Before migration, please make sure that 'appId' has been configured in the CrashSight backend console (add the corresponding item). After triggering a crash or Bugly log, please go to CrashSight Console for verification. Example: BUGLY_REPORT_URL_ANDROID = https://test-astat.bugly.qcloud.com/rqd/async; Version 3.3.19 starts to support it |
MSDK_DENIED_COLLECT_LIST | Android | Apn&AndroidID&QImei&QImei36 collection configuration switch; the fields that are not allowed to be collected can be configured in this configuration item (multiple fields are connected with English commas), and the collection of them is allowed by default if they are not configured; supported since version 3.3.25 |
CLOSE_BUGLY_CALLBACK | Android | Crash reporting callback and error reporting callback switches; if they are set to false, this means to enable the callbacks; if they are set to true, this means to disable the callbacks; if they are not configured, the callbacks will be enabled by default. 3.3.26 version starts to support them |
DELETE_ACCOUNT_URL_TEST | Android | The account cancellation page's test environment url, currently configured as: https://gacc-account-web-test.odp.qq.com/writeoff.html; 3.3.271 version starts to support this |
DELETE_ACCOUNT_URL_RELEASE | Android | The account cancellation page's release environment url, currently configured as: https://gacc-account-web.odp.qq.com/writeoff.html; 3.3.271 version starts to support this |
2.16.0 and above; Precautions:
If MSDK is upgraded to 2.16.0 from an earlier version, the configuration file msdkconfig.ini needs to make the following changes
1. Add MSDK's domain name configuration (the game does not need to modify it but directly copy it into the configuration file)
;the following configuration is for MSDK's internal use, and game developers don't need to pay attention to it
MSDK_ENV_TEST_URL=http://msdktest.qq.com
MSDK_ENV_RELEASE_URL=http://msdk.qq.com
2. Add domain name selection configuration (The game chooses the right environment according to the situation)
;selection of the formal environment and the test environment; "test" means the test environment, and "release" means the formal environment
MSDK_ENV=test
3. Delete the original domain name configuration scheme(delete MSDK_URL=xxxxx)
;selection of the formal environment and the test environment; msdktest.qq.com is the test environment's domain name, and msdk.qq.com is the formal environment's domain name
MSDK_URL=http://msdktest.qq.com (delete)
Please refer to MSDKDemo's configuration file
2.18.0 and above; Precautions:
If MSDK is upgraded to 2.18.0 from an earlier version before 2.16.0, the configuration file msdkconfig.ini needs to make the following changes
1.Add domain name selection configuration (The game chooses the right environment according to the situation)
;selection of the formal environment and the test environment; "test" means the test environment, and "release" means the formal environment
MSDK_ENV=test
2.Delete the original domain name configuration scheme(delete MSDK_URL=xxxxx
;selection of the formal environment and the test environment; msdktest.qq.com is the test environment's domain name, and msdk.qq.com is the formal environment's domain name
MSDK_URL=http://msdktest.qq.com (delete)
3.MSDKLibrary project res/values / msdk_properties.xml adds files. Note: update and merge them
Execute only 2 and 3 steps to upgrade from 2.16.0 to 2.18.0
Please refer to MSDKDemo's configuration file
6 Initialize code
1) Import MSDK package
Import MSDK package into the java code which need to use MSDK interfaces
import com.tencent.msdk.api.WGPlatform;
2) Register login callback and platform launch callback
Because the login callback and the platform launch callback can be invoked when the game does not call relevant interfaces, they need to be registered before the game initializes MSDK. - Login callback: As for the login event result notification, the login state of the game in mobile QQ/WeChat is based on login callback. As for the detailed settings, please refer to the login modulecallback settings. - Platform launch callback: After the game is launched in mobile QQ/WeChat, it will call this callback, including the launched account, the platform's passthrough data and other information. As for detailed settings, please refer to the login module Account inconsistency handling.
WGPlatform.WGSetObserver(new WGPlatformObserver() {
@Override
public void OnWakeupNotify(WakeupRet wakeupRet) {
// TODO GAME Add the logic to handle account inconsistency here
if (CallbackFlag.eFlag_Succ == wakeupRet.flag || CallbackFlag.eFlag_AccountRefresh == wakeupRet.flag) {
// After the local account login succeeds, directly enter the game
// Game TODO:Enter the game logic
if(EPlatform.ePlatform_Weixin.val() == wakeupRet.platform) {
//"WeChat login succeeds";
} else if (EPlatform.ePlatform_QQ.val() == wakeupRet.platform) {
//"QQ login succeeds";
} else if(EPlatform.ePlatform_QQHall.val() == wakeupRet.platform) {
//"Hall login succeeds";
}
} else if (CallbackFlag.eFlag_UrlLogin == wakeupRet.flag) {
// The local has no account information. Automatically login the game with the launched account. The login result is called back in OnLoginNotify()
} else if (CallbackFlag.eFlag_NeedSelectAccount == wakeupRet.flag) {
// Game TODO: In case of account inconsistency, the game needs to pop up a prompt box to allow the user to select the account needing to login and calls WGSwitchUser interface according to the user's choice
//"Account inconsistency!";
} else if (CallbackFlag.eFlag_NeedLogin == wakeupRet.flag) {
// Game TODO: No valid token. Logout of the game so that the user re-login the game
//"Login failed";
//"Please re-login";
} else {
//"Not login";
//message = "OnWakeupNotify flag : " + wakeupRet.flag + "\ndesc : " + wakeupRet.desc;
WGPlatform.WGLogout();
}
}
@Override
public void OnShareNotify(ShareRet ret) {
// TODO Auto-generated method stub
}
@Override
public void OnRelationNotify(RelationRet relationRet) {
if (relationRet.flag == CallbackFlag.eFlag_Succ) {
// Query the relation chain successfully
} else {
// Query the relation chain unsuccessfully
}
}
@Override
public void OnLoginNotify(LoginRet loginRet) {
switch (loginRet.flag)
{
case CallbackFlag.eFlag_Succ:
// Login succeeds; various tokens can be read
// Game TODO: Enter the game
int platform= loginRet.platform;
if(EPlatform.ePlatform_Weixin.val() == platform) {
//"WeChat login succeeds";
} else if(EPlatform.ePlatform_QQ.val() == platform) {
//"QQ login succeeds";
} else if(EPlatform.ePlatform_QQHall.val() == platform) {
//"Hall login succeeds";
}
break;
// Game TODO: Login failure cases should be handled, respectively. In such cases, the handling way is generally to return back to the login page and to guide the user to reauthorize
case CallbackFlag.eFlag_QQ_UserCancel:
// The player cancels authorization
case CallbackFlag.eFlag_QQ_LoginFail:
// QQ Login failed
case CallbackFlag.eFlag_QQ_NotInstall:
// QQ is not installed
case CallbackFlag.eFlag_Local_Invalid:
// Automatic login failed, due to the local token expiration, refresh failure and other errors
case CallbackFlag.eFlag_WX_UserCancel:
// The player cancels authorization
case CallbackFlag.eFlag_WX_NotInstall:
// WeChat is not installed
case CallbackFlag.eFlag_WX_NotSupportApi:
// WeChat version is not supported
case CallbackFlag.eFlag_WX_LoginFail:
//WeChat login failed
default:
//"Login failed";
//loginRet.ToString();
break;
}
}
@Override
public void OnLocationNotify(RelationRet relationRet) {
// TODO Auto-generated method stub
}
@Override
public void OnLocationGotNotify(LocationRet locationRet) {
// TODO Auto-generated method stub
}
@Override
public void OnFeedbackNotify(int flag, String desc) {
// TODO Auto-generated method stub
}
@Override
public String OnCrashExtMessageNotify() {
// TODO Auto-generated method stub
return null;
}
@Override
public byte[] OnCrashExtDataNotify() {
// TODO Auto-generated method stub
return null;
}
@Override
public void OnAddWXCardNotify(CardRet ret) {
// TODO Auto-generated method stub
}
});
4) Initialize MSDK's JAVA layer and set mobile QQ's authorization permissions
Initialize MSDK's C# layer and set mobile QQ's authorization permissions, that is, complete Unity version's initialization operation. After this, call MSDK interfaces according to each module's description; and according to Step 5, pack the game package and verify the real environmental results.
/***********************************************************
* TODO GAME Required to be seen for access. baseInfo value varies with game. When filling in it, please notice the following description:
* baseInfo value; if the game fills in it wrongly, this can lead to failure in QQ and WeChat sharing as well as login failure. Keep this in mind! ! !
* Games which can only access a single platform do not fill in other platforms' information. Otherwise, this can lead to the failure of getting notices
* OfferId is required, and it is directly registered on mizu's official website midas.qq.com
to generate offerId.If you are not a registered midas, you can fill in the appid of mobile QQ temporarily,the offerid generated by the midas is used after registration. If the offerid is not filled in, the login will fail
***********************************************************/
MsdkBaseInfo baseInfo = new MsdkBaseInfo();
baseInfo.qqAppId = "100703379";
baseInfo.qqAppKey = "4578e54f**********c734514e";
//2.18.0 version has deleted qAppKey field
baseInfo.wxAppId = "wxcde873f99466f74a";
baseInfo.msdkKey = "5d1467a4d**********289965db335f4";
baseInfo.offerId = "100703379";
// TODO GAME Since 2.7.1a, game developers can dynamically set the version number in the initialization of msdk. The version numbers of Beacon and Bugly are set by msdk in a unified way
// 1. The composition of version number = versionName + versionCode
// 2. If a game does not assign a value to appVersionName (or fill in"") and appVersionCode (or fill in -1),
// msdk will by default read android:versionCode="51"and android:versionName="2.7.1"in AndroidManifest.xml
// 3. If the game passes in appVersionName (non-null) and appVersionCode (positive integer) here (as shown below), the version number obtained from Beacon and Bugly is 2.7.1.271
baseInfo.appVersionName = "2.15.0";
baseInfo.appVersionCode = 68903;
// Note: The passed-in initialized activity, that is, "this", can not be destroyed during the operation period of the game; otherwise, it will cause Crash
WGPlatform.Initialized(this, baseInfo);
// Set the item which needs the user's authorization when QQ is launched
WGPlatform.WGSetPermission(WGQZonePermissions.eOPEN_ALL);
Note:
-
If WGSetPermission is not called, this may lead to the "100030" error when mobile QQ friends are drawn. For details, please refer to the login module's Outline part's Authorization page description.
-
If the game uses C++ interfaces, it is required to set C++ callback behind the calling of java's initialization interface (WGPlatform.Initialized).
5) Set the calling of Android lifecycle function
public void onCreate(Bundle savedInstanceState) {
...
WGPlatform.Initialized(this, baseInfo);
// Set the item which needs the user's authorization when QQ is launched
WGPlatform.WGSetPermission(WGQZonePermissions.eOPEN_ALL);
// Must guarantee that handleCallback is after Initialized
// Must be called in launchActivity's onCreat() and onNewIntent()
// WGPlatform.handleCallback(). Otherwise, this can cause that WeChat login has no callback
WGPlatform.handleCallback(getIntent());
...
}
@Override
protected void onRestart() {
super.onRestart();
WGPlatform.onRestart();
}
@Override
protected void onResume() {
super.onResume();
WGPlatform.onResume();
// TODO GAME Simulate the game's automatic login, where the game needs to add animation
// WGLogin is an asynchronous interface. When ePlatform_None is passed in it, WGLogin will call the local token to verify if the token is valid
// If you have never logged in the game, a flag called eFlag_Local_Invalid will be immediately returned in onLoginNotify. At this time, you should launch the authorization page
// It is advisable to call WGLogin at this time, which should be called after handlecallback.
if(isFirstLogin) {
isFirstLogin = false;
startWaiting();
WGPlatform.WGLogin(EPlatform.ePlatform_None);
}
}
// TODO GAME The game needs to integrate this method and call WGPlatform.onPause()
@Override
protected void onPause() {
super.onPause();
WGPlatform.onPause();
}
// TODO GAME The game needs to integrate this method and call WGPlatform.onStop()
@Override
protected void onStop() {
super.onStop();
WGPlatform.onStop();
}
// TODO GAME The game needs to integrate this method and call WGPlatform.onDestory()
@Override
protected void onDestroy() {
super.onDestroy();
WGPlatform.onDestory(this);
Logger.d("onDestroy");
}
// TODO GAME Call WGPlatform.onActivityResult in onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
WGPlatform.onActivityResult(requestCode, resultCode, data);
Logger.d("onActivityResult");
}
// TODO GAME It is needed to call handleCallback in onNewIntent to submit the data brought by the platform to MSDK to handle
@Override
protected void onNewIntent(Intent intent) {
Logger.d("onNewIntent");
super.onNewIntent(intent);
// TODO GAME Handle the situation that the game is launched
// Must be called in launchActivity's onCreat() and onNewIntent()
// WGPlatform.handleCallback(). Otherwise, this can cause that WeChat login has no callback
if (WGPlatform.wakeUpFromHall(intent)) {
Logger.d("LoginPlatform is Hall");
Logger.d(intent);
} else {
Logger.d("LoginPlatform is not Hall");
Logger.d(intent);
WGPlatform.handleCallback(intent);
}
}
Note:
- Do not forget to declare new Activities in AndroidManifest.xml 2. When overriding Activity's lifecycle, please call the parent class's lifecycle, for example:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
……
}
MSDKPolicy
1 MSDKPolicy Plugin
3.3.15a version starts to add a data compliance plugin. MSDKPolicy is a universal Android data permission compliance process implementation scheme. It integrates user privacy protocol and permission authorization process, and provides quick access for games through the form of configuration. Games can incorporate the plugin into them according to their own needs.User Agreement Update Reference Documentation:https://docs.qq.com/doc/DSnlkYU5SZWhPYmNR
Important: If your project needs to access TDM component, you need to upgrade TDM to a compliant version: V1.9.000 or above.
The process of MSDKPolicy is as follows:
1.1 Import a plugin
Add MSDKPolicy
plugin. You can directly copy MSDKPolicy
completely to the same level directory as that of other plugins, and introduce MSDKPolicy
directory and add dependency on MSDKPolicy
1.2 Modify AndroidManifest.xml
Adjust the startup Activity to MSDKPolicyActivity
. An example is as follows:
<!-- MSDKPolicy data compliance component configuration -->
<activity android:name="com.tencent.gcloud.msdk.core.policy.MSDKPolicyActivity"
android:configChanges = "keyboard|keyboardHidden|screenLayout|screenSize"
android:launchMode="singleTask"
android:theme="@style/MSDKPolicyTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<!-- MSDK_POLICY_TARGET_ACTIVITY is used to specify the first Activity of the app or game that needs to be jumped to at the end of the compliance process-->
<meta-data
android:name="MSDK_POLICY_TARGET_ACTIVITY"
android:value="com.example.wegame.MainActivity" />
<meta-data android:name="MSDK_POLICY_DEBUG" android:value="true"/>
<!-- In order to comply with the latest compliance process requirements, MSDK_RESULT_FILE_NAME configuration is closed by default since version 3.3.19 -->
<!-- After this configuration is removed, if the user did not agree to the protocol before, the protocol will be popped up in the case of overwriting installation no matter whether the user has logged in before overwriting installation -->
<!-- If your game is newly connected to MSDKPolicy, it is also recommended to comment out the MSDK_RESULT_FILE_NAME configuration below to meet the latest compliance requirements -->
<!--<meta-data android:name="MSDK_RESULT_FILE_NAME" android:value="WEGAMEDB2"/> -->
<meta-data android:name="IS_MSDK_V5" android:value="false"/>
<!-- If the game does not want to upgrade to the compliant version of TDM, you need to set the following MSDK_POLICY_TDM_REPORT_DISABLE switch to true. Note that after it is turned on, the MSDKPolicy process will not do TDM reporting, and the process cannot be tracked-->
<meta-data android:name="MSDK_POLICY_TDM_REPORT_DISABLE" android:value="false" />
<!-- It is used to mark the protocol version. If the protocol is updated, it will be added up. Please fill in the integer value -->
<meta-data android:name="MSDK_POLICY_VERSION" android:value="1" />
</activity>
Warning:
MSDK_POLICY_TARGET_ACTIVITY
is used to specify the first Activity of the app or game that needs to be jumped to at the end of the compliance process. The value of theMSDK_POLICY_TARGET_ACTIVITY
parameter needs to be adjusted to the startup activity of the game by then.- Please keep the remaining parameters consistent with the example.
- Please use
android: screenOrientation
to configure the screen orientation ofMSDKPolicyActivity
to be the same as that of your game or app for a better experience. - In order to comply with the latest compliance process requirements, MSDK_RESULT_FILE_NAME configuration is closed by default since version 3.3.19. After this configuration is removed, if the user did not agree to the protocol before, the protocol will be popped up in the case of overwriting installation no matter whether the user has logged in before overwriting installation. If your game is newly connected to MSDKPolicy, it is also recommended to comment out the 'MSDK_RESULT_FILE_NAME' configuration below to meet the latest compliance requirements.
1.3 Related documents
- msdk_policy_content.html
It is used to configure the content of the agreement. A default agreement reviewed by the legal department has been provided - msdk_permission_content.html
It is used to configure the permission list and usage instructions required by App. The current content is used for Demo. You need to modify it according to the actual situation of your app. The necessary permissions need to be placed in the front and given with a highlighted prompt like (Required) - Msdk_permission_list in values.xml
It is used to configure the necessary permissions for polling in the permission application process. During the polling process, the necessary permissions will be applied for from the user
1.4 MSDKPolicy is divided into two parts
User privacy protocol:
When the user clicks the App icon to start the game, the user privacy protocol (as shown above) will be launched. The protocol content in the figure can be configured. Currently, a set of default protocol is provided for games. If you want to modify it, please contact the Legal Department to confirm the risk assessment. The protocol content can be configured in the resource file 'MSDKPolicy/assets/msdk_policy_content.html'. Only basic html tags are supported. If chess and card games access it, please contact the Legal Department to confirm the protocol and link address of chess and card games by themselves, and make adjustments accordingly.
<!doctype html>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width initial-scale=1'>
<title></title>
</head>
<body>
<p>Before you use our (Tencent) services, please read carefully and fully understand the terms of the <a href='http://game.qq.com/contract.shtml'>Tencent Games License and Service Agreement</a>, <a href='http://game.qq.com/privacy_guide.shtml'>Tencent Games Privacy Protection Guidelines</a> and <a href='https://game.qq.com/privacy_guide_children.shtml'>Tencent Games Children's Privacy Protection Guidelines</a> and <a href="https://game.qq.com/zlkdatasys/privacy_SDK.html">Third Party Information Sharing Checklist</a> the terms of.<strong>At the same time, you should pay special attention to the clauses that exempt or limit our liabilities, the clauses that restrict your rights, and the clauses stipulating dispute resolution and jurisdiction in the aforementioned agreement. </strong>If you have read in detail and agree to the <a href='http://game.qq.com/contract.shtml'>Tencent Games License and Service Agreement </a>, <a href='http://game.qq.com/privacy_guide.shtml'>Tencent Games Privacy Protection Guidelines</a> and <a href='https://game.qq.com/privacy_guide_children.shtml'>Tencent Games Children Privacy Protection Guidelines</a> and <a href="https://game.qq.com/zlkdatasys/privacy_SDK.html">Third Party Information Sharing Checklist</a> please click "Agree" to start using our services. </p>
</body>
</html>
Required permission application process:
After clicking the "Agree" button, the user enters the permission request page and starts the necessary permission application process, as shown in the following figure:
The content of the permission description page can be configured. Developers need to sort out all the permissions of their own App and list them in the configuration. Among them, the required permissions need to be clearly marked as shown in the above figure. The configuration file is MSDKPolicy/assets/msdk_permission_content.html. Only basic html tags are supported. The following is just an example. Developers need to sort out all the permissions of their own App.
<p>In order to ensure your gaming experience, we will apply for the following permissions during your use of our service. By then, you can choose to agree or refuse to open the relevant permissions. If you refuse, this will affect some functions:</p>
<br/>
<p><strong>Save permissions </strong></p>
<p>Cache images/videos to reduce traffic consumption</p>
<br/>
<p><strong> Device/phone permissions </strong></p>
<p>Verify IMEI&IMSI code to prevent account theft</p>
<br/>
<p><strong>Location permission </strong></p>
<p>Get your location information, so that you can play with nearby players</p>
<br/>
</ul>
When the user clicks the "Confirm" button on the permission request page, the application process of required permissionstarts.
During this process, users will be polled to obtain required permissions. Developers need to configure the required permissions needed by their own App to the msdk_permission_list of MSDKPolicy/res/values/values.xml. The following is just an example. Developers need to sort out all the required permissions needed by their App, for example:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="msdk_permission_list">
<item>android.permission.ACCESS_FINE_LOCATION</item>
</array>
</resources>
The required permission for the geographic location are configured in this example. Then, there will be a pop-up box in the above figure to apply for this permission (if not authorized).
Starting from V3.3.25, msdk_permission_content.html has supported configuration.
If msdk_permission_content.html is set empty or is deleted, the "permission description" page will not be popped up. After the user clicks the "Agree" button on the agreement page, he will directly enter the game.
1.5 Test and verification
- After the user clicks "Agree" on the agreement page, TDM will start to report the in-app event tracking data and the device information. You can contact MSDK Assistant to assist in verification;
- The required permissions in values.xml need to be consistent with the highlighted (required) permissions in msdk_permission_content.html;
- Critical path test: After the access is completed, you must do a critical path test. Paths such as login & relationship & sharing & game center start & account inconsistency must be covered in the test.
2 Switch Configuration Interface
3.3.21 Version add this interface,After the user agrees to the terms of the user agreement, the business can call this interface to enable MSDK and the third-party components included in the MSDK (currently, there are beacon and TBS components that support this capability) to obtain relevant information; MSDK will not obtain the relevant information until the switch is turned on. Related Information. The interface description is as follows:
java:
MSDKSensitive.setCouldCollectSensitiveInfo(true);
c++:
/*
* Set whether to allow access to related information
*/
void WGSetCouldCollectSensitiveInfo(bool couldCollect);
Warning:
- Before MSDK is initialized, you can call the Java interface to turn on the switch in advance to avoid some data reporting from missing sensitive information fields.
- If the Java interface is not called before MSDK is initialized, the C++ interface must be called after MSDK is initialized.
- Multi-process scenes are not supported. It is recommended to place all the calls for internal policy optimization related interfaces into the main process, or the child process calls the related interfaces of the component by itself.
- 【Warning】QQ OpenSDK 3.5.7 version has updated permission-related functions. The accessing party cannot use QQ OpenSDK's functions before calling WGSetCouldCollectSensitiveInfo. The log will print "The user is not authorized and is temporarily unable to use QQ login and sharing functions".
3 Set Info Field Interface
3.3.21 Version adds a new interface for setting the information field,After the user agrees to the terms of the user agreement, the service can obtain the relevant information fields by itself, and call this interface to set up the MSDK and the third-party components included in the MSDK (the lighthouse component currently supports this capability). The interface description is as follows:
java:
MSDKSensitive.setSensitiveInfo("{\"AndroidID\":\"xxx\", \"WiFiMacAddress\":\"xxx\", \"Model\":\"xxx\", \"Oaid\":\"xxx\", \"Imsi\":\"xxx\", \"Cid\":\"xxx\"}");
c++:
/*
* Set the information fields to each component SDK in the json form; currently support{"AndroidID":"xxx","WiFiMacAddress":"xxx","Model":"xxx","Oaid":"xxx","Imsi":"xxx","Cid":"xxx"}
*/
void WGSetSensitiveInfo(const char *jsonInfo);
Warning:
- Before MSDK is initialized, you can call the Java interface to set relevant information in advance to avoid some data reporting from missing relevant information fields.
- If the Java interface is not called before MSDK is initialized, the C++ interface must be called after MSDK is initialized.
- The
AndroidID
field must be set; otherwise, the Beacon data statistics will be affected. - Not passing in the
Model
value can affect Beacon's middle-end algorithm effect
4 Apn & AndroidID & QImei & QImei36 collection configuration interface switch
Version 3.3.25 Add Apn & AndroidID & QImei & QImei36 collection configuration interface switch;based on their own needs, games can configure whether these fields are allowed to be collected (this interface function is the same as the MSK_DENIED_COLLECT_LIST
configuration item in the msdkconfig.ini file, but its priority is higher than the latter's). The interface description is as follows:
/**
* Set the special information single-field switch in the form of json; its priority is lower than that of the general switch; currently support setting AndroidID, Apn, QImei and QImei36
* Parameter example{"AndroidID":true,"Apn":true,"QImei":true,"QImei36":true}
*
*/
void WGSetCollectSensitiveInfo(const char *jsonInfo);
Target API 28 Upgrade Guide
1. Background
Google Play Store requires Apps that go online after August 2019 and are updated after November must upgrade their Target API to Target API 28
Official reference materials:
> When you upload an APK, it needs to meet Google Play's target API level requirements. Starting August 1, 2019, Google Play requires that new apps target at least Android 9.0 (API level 28), and that app updates target Android 9.0 from November 1, 2019. Until these dates, new apps and app updates must target at least Android 8.0 (API level 26).
2. How to be upgraded to Target API 28
Simply put, modify the value of the compiled targetSdkVersion
to 28
2.1 Android Studio and Gradle compilation projects
Generally in the build.gradle
file in the App directory,
modify the value of android
->defaultConfig
->targetSdkVersion
to 28
, such as:
2.2 Unity projects
In the Unity menu's File
->Build Settings...
pop-up window, select Android
in Platform
, and in Player Settings...
open the Inspector
panel and find Other Settings
->Target API Level
and then make settings in it
2.3 UE4 Projects
Open the pop-up window in the UE4 menu's File
->Package Project
->Packaging Settings...
,
and find the Platforms
->Android
configuration item and then modify the corresponding configuration
3. Configuration and processing
3.1 Network security processing
Android 9 already uses the encrypted network protocol (HTTPS) by default. For non-HTTPS requests, you need to add a configuration or a whitelist for network security processing
Note: When using Webview, you cannot open non-whitelisted HTTP websites.
Google upgrade instructions: https://developer.android.com/about/versions/pie/android-9.0-changes-28#tls-enabled
3.1.1 Add global configuration
If you use the global configuration, add the attribute android:usesCleartextTraffic="true"
in the application
node in AndroidManifest.xml
:
3.1.2 Add a domain name whitelist
Configuration method:
- In the
application
node inAndroidManifest.xml
, add theandroid: networkSecurityConfig="@xml/network_security_config"
attribute
xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="@xml/network_security_config"... >
...
</application>
</manifest>
- Add the file
res/xml/network_security_config.xml
and configure the domain name information:
xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config>
<domain includeSubdomains="true">pingma.qq.com</domain>
<domain includeSubdomains="true">182.254.116.117</domain>
<domain includeSubdomains="true">android.bugly.qq.com</domain>
</domain-config>
</network-security-config>
For more configuration information, please refer to: https://developer.android.com/training/articles/security-config.html
3.2 Apache HTTP library support
If the Apach HTTP library is used in your app, you need to add the following configuration under the application
node in AnroidManifest.xml
to ensure normal operation on Android 9
<uses-library android:name="org.apache.http.legacy" android:required="false" />
3.3 Webview multi-process data directory restrictions
Android 9 restricts Webview's directory access. MSDK uses a multi-process Webview to ensure that the memory is released normally. Games need to upgrade the Android Webview component:
- 1.15.3 and above (games accessing WebView before mid-2017)
- 2.2.8 and above version (games accessing WebView after mid-2017)
Note: Due to multi-process file directory restrictions, cookies and file data cannot be shared between Webviews
4. Component SDK upgrade
4.1 Beacon
- Version requirements
The SDK version of Beacon needs to be >= 3.0.4
- Upgrade method
- Replace the original plugin with the new version of plugin
- Unzip the jar package, and use the beaconcomp
directory to replace the assets/beaconcomp
directory file in the original project directory
4.2 PUSH
- Version requirements
PUSH must be upgraded to Tencent Mobile Push TPNS version
- Upgrade method - Replace the original plugin with the new version of plugin
4.3 Bugly
- Version requirements
It is recommended to upgrade Bugly to the latest version Java SDK 2.8.6, NDK 3.6.0
- Upgrade method - Replace the original plugin with the new version of plugin
4.4 TBS Webview
-
Version requirements - The MSDK plugin must be upgraded to solve the multi-process data directory sharing problem - TBS SDK can be supported and is not necessary to upgrade
-
Upgrade method - Replace the original plugin with the new version of plugin
5. Precautions about upgrade
5.1 Environmental requirements
For Unity and UE4, please separately check whether Android SDK and build-tools directories have been correctly upgraded to the specified Target 28 version. The versions specified by MSDK are as follows:
compileSdkVersion: 28,
buildToolsVersion: '28.0.3',
minSdkVersion : 15,
targetSdkVersion : 28,
Among them, buildToolsVersion has been upgraded to Target 28, the highest stable version.
MSDK Android permission list
Channel | Required permission | Optional permission | Purpose of use |
---|---|---|---|
MSDK | 1、android.permission.INTERNET(network) | 4、android.permission.WRITE_EXTERNAL_STORAGE(external storage) | 1、Network communication 4、Write data to external storage for the persistence of program information and the storage of log files, sharing image and others; lack of this permission can affect the sharing function of externally stored images/videos |
2、android.permission.ACCESS_NETWORK_STATE | 5、android.permission.READ_EXTERNAL_STORAGE | 2、Used for built-in WebView to get network status to sense network changes 5、Read data from external storagefor the persistence of program information and the storage of log files, sharing image and others; lack of this permission can affect the sharing function of externally stored images/videos |
|
3、android.permission.CHANGE_NETWORK_STATE | 6、android.permission.ACCESS_COARSE_LOCATION(rough location) | 3、Operator password-free login authentication for built-in WebView(carrier number agreement) 6、Provide LBS location information service to the game; the game can obtain the latitude and longitude as well as the information of nearby players through the interface, so that the player can interact with their surrounding players. If your game does not require the LBS function, you don't need to configure this permission |
|
7、android.permission.ACCESS_FINE_LOCATION(precise location) | 7、Provide LBS location information service to the game; the game can obtain the latitude and longitude as well as the information of nearby players through the interface, so that the player can interact with their surrounding players. If your game does not require the LBS function, you don't need to configure this permission | ||
8、android.permission.CAMERA(camera) | 8、Can visit the camera in the webpage. If your game doesn't require this function, you don't need to configure this permission | ||
1、android.permission.INTERNET(network) | 1、Network communication | ||
2、android.permission.ACCESS_NETWORK_STATE(network state) | 2、Sense network changes | ||
- | - | - | |
Bugly | 1、android.permission.INTERNET(network) | 1、Network communication | |
2、android.permission.ACCESS_NETWORK_STATE(network state) | 2、Sense network changes | ||
QIMEI | 1、android.permission.INTERNET(network) | 1、Network communication | |
2、android.permission.ACCESS_NETWORK_STATE(network state) | 2、Sense network changes | ||
Beacon | 1、android.permission.INTERNET(network) | 1、Network communication,for data reporting | |
2、android.permission.ACCESS_NETWORK_STATE | 2、Sense network changes,Used to adjust data reporting policies | ||
3、android.permission.ACCESS_WIFI_STATE | 3、Get Wifi status and information to adjust data reporting policy | ||
TBS | 1、View web link | 2、clipboard | 1、A network connection is required when opening web content through the SDK 2、The user actively operates the copy and paste of the content of the webpage or file |
3、View geographic location | 3、The user actively opens a third-party web page, and the web page itself needs to locate the location | ||
TPNS | 1、Application package name.permission.XGPUSH_RECEIVE(customize) | 7、com.huawei.android.launcher.permission.CHANGE_BADGE(Huawei Custom Permissions) | 1、Permissions pushed using TPNS 7、Permission to use Huawei device corner label function |
2、android.permission.INTERNET | 8、com.vivo.notification.permission.BADGE_ICON(Vivo custom permissions) | 2、Allows programs to access network connections, possibly generating GPRS traffic 8、Permission to use vivo device corner label function |
|
3、android.permission.ACCESS_WIFI_STATE | 9、android.permission.VIBRATE | 3、Allows the program to obtain the current Wi-Fi access status and information about WLAN hotspots 9、Allow app to vibrate |
|
4、android.permission.ACCESS_NETWORK_STATE | 10、android.permission.RECEIVE_USER_PRESENT | 4、Allows programs to obtain network information status 10、Allows apps to receive screen-lit or unlocked broadcasts |
|
5、android.permission.SCHEDULE_EXACT_ALARM | 11、android.permission.WRITE_EXTERNAL_STORAGE | 5、Allow scheduled broadcast 11、Allow programs to write to external storage |
|
6、android.permission.WAKE_LOCK | 12、android.permission.RESTART_PACKAGES | 6、Allows background processes to run even after the phone's screen is turned off 12、Allow the program to end the task |
|
13、android.permission.GET_TASKS | 13、Allows programs to obtain task information |
FAQ
1 Checking the reasons why Android WeChat can't be logged in
Step 1: Check whether there is the following sentence in Log
lauchWXPlatForm wx SendReqRet: true
If there is this sentence in Log, this indicates that the request has been successfully sent to WeChat
If WeChat client can't be launched, please check Step 2, If WeChat client is pulled up, but no callback, check Step 3
Step 2: Check the signature and the package name
Download https://res.wx.qq.com/open/zh_CN/htmledition/res/dev/download/sdk/Gen_Signature_Android2.apk, install this apk into the mobile phone, enter the package name of the game in the input box and click the button to read the game package's signature.
Check whether the signature obtained by the above tool is consistent with the signature of WeChat backend configuration (WeChat background configuration signature information query, please RTX contact MSDK)
Step 3: Check the location where WXEntryActivity.java is placed (this file is in MSDKSample)
This file must be placed under the game+.wxapi. For example, if the package name of the game is: com.tencent.msdkgame, WXEntryActivity.java should be placed under com.tencent.msdkgame.wxapi. At the same time, check if the content of WXEntryActivity is consistent with the following content
/**
* !!Users can't modify the code logic part of the file. Starting from MSDK 1.7, the parent class name is changed from WXEntryActivity to BaseWXEntryActivity. If this file fails to work correctly, please check this item at first
*/
public class WXEntryActivity extends com.tencent.msdk.weixin.BaseWXEntryActivity { }
If this step has no problem, please see the fourth step
Step 4: Check handleCallback
Check if WGPlatform.handleCallback is called in onCreate and onNewIntent of the game's Launch Activity.
Step 5: Check if the game's global Observer is set correctly
Check if the game calls WGSetObserver correctly (C++ layer and Java layer).
2 Precautions on Access to WeChat
- In order to prevent any white box from appearing to affect the user experience after the screen returns from WeChat authorization, the theme can be set to
"Theme.Translucent.NoTitleBar"
. If this transparent theme is used, it is needed to setandroid:screenOrientation="portrait"
at the same time. Otherwise, WeChat login will have exceptions. - Place
WXEntryActivity.java
file underthe application's package name+.wxapi
. - In WeChat-accessing Activity, there are
three places which the game needs to modify them by itself
(marked in the above demo).