Outline
MSDK is developed and provided by Tencent IEG for self-development and third-party mobile game development teams. It aims to help games quickly access various major platforms of Tencent and public components and service libraries running online.
Access Guide
1 Preconditions
1)At first, you need to confirm that you have acquired MSDK iOS version. If you have not acquired it, click the link below to download it.
2)The environment which has installed Xcode 7.0 and higher versions is required.
2 installation package structure
MSDK's iOS version package includes demo Demo
as well as libstdc++ and libc++ versions of library framework
, which is saved in MSDKDemo/Library
directory, as shown in the figure below:
Wherein, libstdc++ version in the folder name without _C11 applies to projects which are configured as GNU++98 in "Build Setting->C++ Language Dialect" and as "libstdc++(GNU C++ standard library)" in "Build Setting->C++ Standard Library";
libc++ version in the folder name carrying _C11 applies to projects which are configured as GNU++11 in "Build Setting->C++ Language Dialect" and as “libc++(LLVM C++ standard library with C++11 support)" in "Build Setting->C++ Standard Library".
Note: If you use XCode10 and adapt to iOS12, you need to use C11 library files.
3 Import MSDK
According to the needs, import different frameworks into the project via Target->Build Phases->Link Binary With Libraries
, as shown in the figure below.
Precautions
1) In addition to accessing MSDK.framework
and MSDKMarketing.framework
, games that access real-name registration and inside webview need to import resource files like MSDKResources.bundle
and WGPlatformResources.bundle
into the project via Target->Build Phases->Copy Bundle Resources
. Otherwise, some problems will appear, such as the real-name registration page may miss button images, and the inside webview may crash when it is launched.
2)After some games import framework, they may be unable to find framework. The phenomenon is that the inside webview can’t be opened and the log exports "No MSDKWebViewService exists". At this time, it is needed to add -ObjC
and -framework MSDKMarketing
to Other link flags
, as shown in the figure below:
4. Import system dependency library
libz.tdb
libstdc++.tdb//Games that use C11 version need to use libc++.tdb
libz.1.1.3.tdb
libsqlite3.tdb
libxml2.tdb
CoreTelephony.framework
SystemConfiguration.framework
UIKit.framework
Foundation.framework
CoreGraphics.framework
MobileCoreServices.framewrok
StoreKit.framework
CFNetwork.framewrok
CoreData.framework
Security.framework
CoreLocation.framework
ImageIO.framework
CoreText.framework
QuartzCore.framework
AdSupport.framework
UserNotifications.framework
Precautions
Starting from version 3.3.8i, the UserNotifications.framework library needs to be set as optional, otherwise this library cannot be found under iOS10.
5 Configure the game information
The following fields' game information must be configured in the project's info.plist
file. Each field's value can be gotten at the Flying Eagle system (dev.ied.com) through your game operation manager.
Field | Type | Description |
---|---|---|
MSDKKey | String | ID used for the interaction between the MSDK frontend and the backend of the game |
QQAppID | String | AppId of a game in the mobile QQ development platform |
QQAppKey | String | AppKey of a game in the mobile QQ development platform (no need to configure QQAppKey any more in versions later than 2.18.0) |
WXAppID | String | the game's AppId at WeChat development platform |
MSDK_OfferId | String | Midas platform iOS payment OfferId. At first, ask the game’s operation manager to apply for Apple information at RDM’s official website (rdm.oa.com). After the application, send the information via RTX to Flying Eagle Assistant , which will input the information into the Flying Eagle’s backend. Then, the developer will add IAP version in the open platform management center. After this, offerid will be generated automatically according to the direction |
6 Configure MSDK-related information
The following fields are configuration information in relation to MSDK functions, and they can be configured in the project's info.plist
file according to the game's needs. Their specific configuration and explanation are as follows:
Field | Type | Description |
---|---|---|
MSDK_ENV | String | environment selection; MSDK can choose the test environment in case of joint debugging; after its official release, it must choose the formal environment |
AutoRefreshToken | Boolean | MSDK WeChat automatic refresh token switch, which is defaulted to be "ON". For details, please refer to login module |
MSDK_PUSH_SWITCH | Boolean | Pigeon push function switch, which is defaulted to "OFF" |
NeedNotice | Boolean | MSDK notice function switch, which is defaulted to "OFF" |
NoticeTime | Number | MSDK notice system's notice data update time (request notice data when going online), in seconds (300s at least); the default value is 600s |
MSDK_REAL_NAME_AUTH_SWITCH | Number | Real-name authentication configuration(3.2.14 and higher versions must configure it as 1); 0: Use MSDK’s real-name authentication UI, and return to the login page after authentication; 1: Use MSDK’s real-name authentication UI, and login the game after authentication; 2: Use the game’s self-defined authentication UI, and call back to the game after authentication; |
CHANNEL_DENGTA | String | iOS system channel number |
NSLocationWhenInUseUsageDescription | String | used in LBS positioning function in iOS8; the value can be null |
MSDK_Webview_Portrait_NavBar_Hideable | Boolean | Switch used to indicate whether or not to hide inside webview’s portrait navigation bar; default: OFF |
MSDK_Webview_Landscape_NavBar_Hideable | Boolean | Switch used to indicate whether or not to hide the landscape navigation bar; default: OFF |
MSDK_DO_BEACON_EVENT_IP_SWITCH | String | Used as Msdk's internal beacon reporting switch; 1: Turn on by default |
MSDK_DO_BEACON_EVENT_SWITCH | String | Used as Msdk's internal beacon reporting switch; 1: Turn on by default |
SCOPE | String | Extended WeChat scope field; multiple scopes are separated with ", "; version 2.18.0 starts to support this |
IPV6_SUPPORT | Boolean | 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 |
MSDK_PUSH_AT_FOREGROUND | Boolean | XG adds the front-end push switch, which is off by default; 3.3.10 version starts to support the field |
MSDK_Webview_Force_Adapt_Bang_Screen | Boolean | Built-in Webview full-screen configuration switch; if the switch is configured to 'true', MSDK's built-in WebView will be displayed in full screen when it is in the landscape mode; if the switch is configured to 'false' or not configured, MSDK's built-in WebView behavior will be consistent with that of the previous version. Version 3.3.11 starts to support this switch |
MSDK_WEBVIEW_LOADING_BACKGROUND_COLOR | String | 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 it |
MSDK_BUGLY_BLOCK_MONITOR_ENABLE | Boolean | Bugly block monitoring configuration switch; when the switch is set as 'true', this means 'enabled'; if it is not configured, it will be disabled by default; 3.3.15 version starts to support it |
MSDK_BUGLY_BLOCK_MONITOR_TIMEOUT | Number | After Bugly block monitoring is enabled, you need to configure the block monitoring judgment interval, whose unit is second; it is default as 5 seconds if it is not set; 3.3.15 version starts to support it |
MSDK_CENTER_CONTROL_WEBVIEW_LOADING_BACKGROUND_COLOR | String | A switch for the background color of the loading page loaded when the central control Webview is opened; the default color is: #010C0F; 3.3.16 version starts to support it |
CLOSE_BEACON_REPORT | Boolean | Beacon reporting switch, which is 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 is defaulted as 'enabled'; 3.3.17 version starts to support it |
CLOSE_HTTPDNS | Boolean | HttpDns switch, which is defaulted as false; if it is set to true, this means to close the HttpDns function; if it not configured, it is defaulted as 'enabled'; 3.3.17 version starts to support it |
STAT_LOG | Boolean | 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 or remove the configuration; 3.3.19 version starts to support Beacon and Bugly; 3.3.271 version starts to support QQ OpenSDK |
BUGLY_REPORT_URL_IOS | String | 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; 3.3.19 version starts to support it |
CLOSE_BUGLY_CALLBACK | Boolean | Crash reporting callback switch; 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 | String | 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 | String | 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 |
QQSdkWebviewScreenDir | Number | In iOS16, if the QQ client is not installed, this configuration can solve the problem that a landscape mode game cannot switch back to the landscape mode when the screen returns to the game after the game invokes QQ website for the player to log in. If the following configuration values are obtained, they mean: 0: screen orientation neutral, 1: landscape mode, 2: portrait mode. If the above configuration values are not obtained, the screen orientation that exists when APP logs in will be obtained. If the screen orientation exists, the obtained screen orientation will be returned. Otherwise, screen orientation neutral will be returned. 3.3.271 version starts to support this |
IDFA iOS 14 description
Applicable version: MSDK V3.3.15 and later versions
In iOS 14, Apple has further tightened user privacy permissions. When you collect IDFA, a user authorization pop-up window will pop up and you are required to add a new configuration in info.plist and to fill in the purpose of collecting IDFA. Developers can call the IDFA acquisition interface as needed to pop up a notification for the user, asking the user whether to authorize this. If the user does not authorize this, the collected IDFA will be a string of meaningless 00000-000000000-000000. IDFA acquisition is modularized. By adding MSDKSensitivity.framework
, developers can access this function on demand.
- Xcode-Build Phases-Link Binary With Libraries adds
AppTrackingTransparency.framework
. - In the info.plist file, add a key-value pair, where the key is
Privacy-Tracking Usage Description
and the value is the reason for using IDFA.
Call the following API to pop up an authorization pop-up window for the user:
#import <AppTrackingTransparency/AppTrackingTransparency.h>
if (@available(iOS 14.0, *)) {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
}];
}
MSDK has provided a switch for compatible IDFA collection since version 3.3.16, as follows:
Add a key-value pair to the info.plist file of the development project, where the value is MSDK_APP_TRACKING_ENABLE
and the value is YES
or NO
- YES: The game still needs to call the above AppTrackingTransparency.framework API when necessary to pop up an authorization pop-up window for the user, asking whether the user allow the IDFA collection. MSDK can also call the relevant API to query the user's authorization status. Only the user authorizes this can the interface be called to obtain IDFA; otherwise MSDK will directly return a meaningless string like 00000-000000000-000000.
- NO: MSDK directly calls Apple API's IDFA acquisition interface.
The default behavior of not adding MSDK_APP_TRACKING_ENABLE
is NO
.
If you want to delete the IDFA related functions of MSDK itself, do the following operations:
- Delete the declaration of IDFA in info.plist
- Delete MSDKSensitivity.framework
- Delete AdSupport.framework
- Delete AppTrackingTransparency.framework
CAID description
Applicable version: MSDK V3.3.17 and later versions
CAID: It is a set of IOS device ID for domestic advertising collaborative promotion. After Apple's IDFA cannot be read, CAID solves the advertising attribution problem. Games that require CAID acquisition and reporting need to integrate the TGPA component tgpasimple.framework
in the MSDK release package by themselves. MSDK can acquire and report CAID internally through reflection calls.
Warning:
- The acquisition and reporting of CAID only supports iOS 9.0 and above systems. The TGPA component of systems below iOS 9.0 cannot obtain CAID.
- Because the acquisition of CAID requires access to the network, the acquisition and reporting of CAID may fail for the first-time installation or reinstallation scenario. After the failure, CAID can be re-acquired, and it will be visible next time you start to log in.
7 Configure Scheme white list and ATS information
Due to the limitation of iOS9 system, Mobile QQ and WeChat’s authorization and share functions can’t be normally launched until "Go to Scheme white list" is configured in the info.plist
file. Otherwise, errors like "-canOpenURL:failed for URL:"mqq://" - error: “This app is not allowed to query for scheme mqq"" will appear when the authorization and share functions are launched, leading to failure in authorization and sharing. In addition, support for http transmission should be configured; otherwise, all http requests from systems higher than iOS9 will be shielded (there is no need to configure ATS for 2.16.0 version. When being reviewed, games that need to continue using ATS statement shall explain this to Apple). The following configuration information can be directly copied into info.plist:
- If the built-in browser (WebView) module skips to a third-party app, it needs to add a whitelist. For example, if it skips to WeChat, it needs to add: weixin, wechat
- Since version 3.3.8, mqqopensdkminiapp and weixinULAPI skip scheme whitelist need to be added in info.plist. Otherwise, unauthorized login and sharing can't work.
- From version 3.3.21, the info.plist adds mqqopensdklaunchminiapp jump scheme whitelist, otherwise mobile QQ cannot be activated normally.
- 3.3.271 version starts to add `mqqopensdknopasteboard`, `mqqopensdknopasteboardios16` and `weixinURLParamsAPI` skip scheme whitelists in info.plist. QQ and WeChat channels need to adapt to the requirement of iOS 16. The app should confirm that they have been added in info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tim</string>
<string>mqq</string>
<string>mqqapi</string>
<string>mqqwpa</string>
<string>mqqbrowser</string>
<string>mttbrowser</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV3</string>
<string>mqqopensdkapiV4</string>
<string>wtloginmqq2</string>
<string>mqzone</string>
<string>mqzoneopensdk</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapiV2</string>
<string>mqqapiwallet</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkdataline</string>
<string>mqqgamebindinggroup</string>
<string>mqqopensdkgrouptribeshare</string>
<string>tencentapi.qq.reqContent</string>
<string>tencentapi.qzone.reqContent</string>
<string>weixin</string>
<string>wechat</string>
<string>weixinULAPI</string>
<string>mqqopensdkminiapp</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
8 Configure URL Types
Games should configure the following URL Scheme in the project setting tab Target->Info->URL Types
, so as to activate the games normally from the platform game center or by clicking the shared message after the platform is authorized. The specific configuration is as follows:
Identifier | URL Scheme | Example | Remark |
---|---|---|---|
weixin | The game's WeChat AppID | wxcde873f99466f74a | Used to access WeChat; required |
tencentopenapi | format: tencent+game's QQAppID | tencent100703379 | Used to access Mobile QQ; required; no space in the middle |
format: QQ+game's QQAppID, which is a hexadecimal number | QQ06009C93 | Used to access Mobile QQ; required; no space in the middle | |
QQLaunch | format:tencentlaunch+game's QQAppID | tencentlaunch100703379 | Used to access Mobile QQ; required; no space in the middle |
The configuration result is shown in the figure below:
9 passthrough URL parameters launched by the platform
The game needs to passthrough the launched URL parameters to MSDK through the method launched by the platform. Otherwise, it can’t receive MSDK's authorized login and share callback. The specific method is - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
method in AppDelegate.m
. A reference example is shown below:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!url == %@",url);
//Initialize MSDK
WGPlatform *plat = WGPlatform::GetInstance();
WGPlatformObserver *ob = plat->GetObserver();
if (!ob)
{
//Set callback
MyObserver* ob = MyObserver::GetInstance();
plat->WGSetObserver(ob);
plat->WGSetADObserver(ob);
plat->WGSetGroupObserver(ob);
}
//Passthrough URL parameters to MSDK
return [WGInterface HandleOpenURL:url];
}
10 Universal Link
10.1 What is Universal Link?
Universal Link is a mechanism introduced by Apple from iOS 9 to open up a skip between Web and App. When a link associated with App is opened in Safari or WebView, it will automatically skip to App without losing any parameter content. Universal Link solves some problems of URL Scheme:
- When a skip fails, a link will be opened directly in Safari/WebView;
- Unify routing on Web and Native with the help of Universal Link;
- No prompt box will pop up when a skip occurs, thus bringing a better experience.
Knowledge about Universal Link can be viewed:
Apple official documentation。
For the access process of Universal Link, please refer toiOS Universal Link tutorial。
Enabling Universal Links。
Apple's official UL test tool。
10.2 Use of Universal Link
To use Universal Link, you need to associate the domain name with App. The association is two-way:
- Authentication of the domain name for App: Place a Json file named apple-app-site-association in the root directory of the Web server. The file describes which path will skip to which app.
- Authentication of App for the domain name: Set up Associated Domains in Xcode and add the domain name into it.
{
"applinks": {
"apps": [],
"details": [{
"paths": ["/app/*", "/qq_conn/1106977030/*"],
"appID": "JBS4AWYMFX.com.tencent.itop.example"
},
{
"paths": ["/reference2/*", "/qq_conn/1106388413/*"],
"appID": "JBS4AWYMFX.com.tencent.imsdk2"
}]
}
}
Precautions:
- The domain name must access Universal Link through HTTPS before it can take effect;
- apple-app-site-association can only be placed in the root directory of the domain name, with no skip;
- The system will request the apple-app-site-association file under the corresponding domain name when App is installed or upgraded for the first time. If Universal Link is unreachable and the configurations are all normal, you can try to restart your mobile phone or reinstall App.
10.3 Operation process of Universal Link
- App is started for the first time or it is started for the first time after its version is updated (the actual result is not reflected in Apple's official documentation);
- App initiates a Get request to the domain name configured in the project to launch the apple-app-site-association Json file;
- App registers apple-app-site-association into the system;
- A skip URL is initiated by any WebView;
- If the universal link registered by apple-app-site-association is hit, open App and trigger Universal Link delegate;
- Otherwise, WebView continues to skip URL.
After apple-app-site-association and app Xcode project are configured, the entire Universal Link operation process is completely controlled by the system.
Summary:When the apple-app-site-association file can't be accessed in Part 2 above, the newly installed apps cannot be logged in by users normally afterwards (you cannot skip back to the game app in WeChat/QQ App authorization UI), unless they are uninstalled and then reinstalled.
10.4 Access MSDK Universal link authorized login capability
10.4.1 MSDK&QQ&WeChat Version support
MSDK version
MSDK has been supported since V3.3.9; integrated into QQ OpenSDK 3.3.7 and WeChat OpenSDK 1.8.6.
QQ App version
QQ App 8.1.3 and above support.
WeChat App version
Supported by WeChat App 7.0.7 and above.
iOS system version
QQ requires iOS13 and above; WeChat requires iOS12 and above.
Precautions:
1. As the QQ platform has now closed the Universal Link authorization login capability of OpenSDK 3.3.6 (MSDK V3.3.8), game developers need to update their OpenSDK versions to OpenSDK 3.3.7 if they want to test such capability of the QQ platform. OpenSDK 3.3.7 has been incorporated into MSDK V3.3.9 version.
2. If there are multiple games in the project team, the Universal Link of each game must be unique, and multiple games cannot share a link.
10.4.2 Add weixinULAPI scheme whitelist
Add weixinULAPI
skip scheme whitelist in info.plist; otherwise, authorized login and sharing can't be performed.
10.4.3 Enable the capability of AppleID Associated Domains
According toApple official documentationcontact the certificate management staff to apply for enabling the capability of AppleID Associated Domains, as shown in the following image:
After AppleID has enabled the capability of Associated Domains, please regenerate the signature description file.
Precautions
Because The enterprise signature certificates of Soda and Bluedon do not have Universal Link capability at this time, game developers please use the development signature certificate for debugging their games.
10.4.4 Feiying System is configured with Universal Link-related information
InFeiying Systemconfigure Universal Link parameters. The configuration path is Feiying Homepage
-> MSDK Management
-> IOS Parameter Configuration
, as shown in the following images:
Remarks: Universal Link is not required to be deployed under the official website domain name, as long as the deployment place is highly available; the following description uses the deployment on the official website as an example to illustrate
Wherein, the Universal Link
column is filled with a sub-directory under the official website of the game and needs to be an https link, such as: https://xxx.com/app/
. Please note that the end must have /
; the URL Scheme
column is filled with the QQ skip scheme of the game in the format of tencent+qqappid
, such as: tencent100703379
. If the business has a separate iPad version, you need to select the iPad version configuration in Flying Eagle. Please select "There is a separate iPad version" in the picture above and fill in the corresponding parameters.
After filling in the columns, click the Update Game iOS Information
button to save the filled information.
Precautions:
1. After saving the filled information, please contact via WeChat the WeChat side's contact person v_chenehe to audit it and open related permissions. 2. If there are QQ-related error prompts, please first do the next step: 10.4.5 Configure apple-app-site-association 3. If there is any error prompt, please contact MSDK Assistant for specific usage methods.
10.4.5 Configure apple-app-site-association
A configuration example is shown as follows:
{
"applinks": {
"apps": [],
"details": [{
"appID": "JBS4AWYMFX.com.tencent.newmsdk2",
"paths": ["/app/*", "/qq_conn/100703379/*"]
},
{
"appID": "JBS4AWYMFX.com.tencent.itop.example",
"paths": ["/app/*", "/qq_conn/1106977030/*"]
}]
}
}
Wherein, the appID
parameter needs to be modified to the game's own signature certificate: team id + bundle id; the/app
character in the paths
parameter must be replaced with the part behind com in the official website address set in the previous step: 10.4.4 Configure Universal Link
, for example, the address configured in the previous step is https://xxx.com/client/
, the /app/*
here needs to be replaced with /client/*
. In addition, the QQ interconnection side requires that the paths
parameter must be configured in the "/qq_conn/QQ AppID/" format, where qq_conn is a fixed field and QQ AppID is filled with the QQ appid of the game itself, such as: /qq_conn/1106977030/, otherwise the verification will fail when Feiying syncs the information to the QQ interconnection. If you want to configure multiple appIDs and paths, please refer to the above examples. After the changes, please save the text as a file named apple-app-site-association
(note: don't add any suffix to the file's name), and place the file in the root directory of the official website address set in the previous step: 10.4.4 Configure Universal Link
. You can download the file normally by visiting the site: https://xxx.com/apple-app-site-association
.
10.4.6 Configure Xcode Capabilities
Under the Capabilities tab of the Xcode project, enable Associated Domains
and configure Domains
. Domains
is fixedly written as applinks: + official website's domain name
. Note: do not add https://
. An example is shown below:
10.4.7 Configure info.plist
In info.plist, add a configuration item whose type is string
, whose name is WX_UNIVERSAL_LINK
and whose value is Universal Link
configured by Feiying System. An example is shown below:
10.4.8 Implement iOS entry function
It is needed to implement the entry function -application:continueUserActivity:restorationHandler:
. The function initializes MSDK and sets related event callbacks. It also calls the interface WGPlatform::GetInstance()->WGHandleOpenUniversalLink((unsigned char *)[urlStr UTF8String]);
to transparently pass related parameters to MSDK. An example is shown below:
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler
{
NSLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!activityType == %@ webpageURL == %@",userActivity.activityType, userActivity.webpageURL);
WGPlatform* plat = WGPlatform::GetInstance();
WGPlatformObserver *ob = plat->GetObserver();
if (!ob)
{
MyObserver* ob = MyObserver::GetInstance();
WGPlatform::GetInstance()->WGSetObserver(ob);
WGPlatform::GetInstance()->WGSetGroupObserver(ob);
WGPlatform::GetInstance()->WGSetWebviewObserver(ob);
WGPlatform::GetInstance()->WGSetEmbeddedWebViewObserver(ob);
}
if (userActivity && [userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb])
{
NSURL *webpageUrl = userActivity.webpageURL;
if (webpageUrl)
{
NSString *urlStr = [webpageUrl absoluteString];
return plat->WGHandleOpenUniversalLink((unsigned char *)[urlStr UTF8String]);
}
}
return YES;
}
Precautions:
Games that access Apollo/GCloud component need to implement this entry function according to the mode of Apollo/GCloud. For details, please consult the development team members of Apollo/GCloud component.
10.4.9 How to verify
Please refer to the WeChat Universal Link access successful verification guidelines Relevant instructions on WeChat official documents。
QQ Universal Link access successful verification guide, please refer to QQ official documentation related instructions。
It is needed to launch the platform's authorized login successfully and launch the platform's sharing successfully, and MSDK's log must contain the isUniversalLink:1
text. A log example is shown in the following image:
The following example is Scheme authorization example. Game developers should distinguish them.
Precautions:
1.Because The enterprise signature certificates of Soda and Bluedon do not have Universal Link capability at this time, game developers please use the development signature certificate for debugging their games.
2.Game developers must verify the authorized login and sharing process according to the acceptance check standard.
11 Set the minimum supported version of the game to iOS8.0 or above
Be sure to set the deployment target of the game to 8.0 or above, otherwise crash will occur in the system running below iOS8.0, the setting method is shown in the following figure:
12 Open Background Modes
Open the Background Modes under the Capabilities tab of the Xcode project and check the Remote notifications option, as shown below:
Initialize MSDK
The game can initialize MSDK and set the callback Observer in the following two game starting entries in AppDelegate.m
. Note: It is needed to first import the header file #import <MSDK/MSDK.h>
.
Entry 1 Start normally
Refer to demos:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//Initialize MSDK
WGPlatform *plat = WGPlatform::GetInstance();
WGPlatformObserver *ob = plat->GetObserver();
if (!ob)
{
//Set callback
MyObserver *ob = MyObserver::GetInstance();
plat->WGSetObserver(ob);
plat->WGSetGroupObserver(ob);
plat->WGSetWebviewObserver(ob);
}
return YES;
}
Entry 2 Launched from the platform
Demo code:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!url == %@",url);
//Initialize MSDK
WGPlatform *plat = WGPlatform::GetInstance();
WGPlatformObserver *ob = plat->GetObserver();
if (!ob)
{
//Set callback
MyObserver* ob = MyObserver::GetInstance();
plat->WGSetObserver(ob);
plat->WGSetADObserver(ob);
plat->WGSetGroupObserver(ob);
}
//Passthrough URL parameters to MSDK
return [WGInterface HandleOpenURL:url];
}
Handle the login callback and the platform launches 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 notification of the login event result, the game's login state in Mobile QQ/WeChat shall be based on the login callback. For specific settings, refer to the login module callback setting. Demo code:
void MyObserver::OnLoginNotify(LoginRet& loginRet)
{
if(loginRet.flag == eFlag_Succ)
{
//login succeeds
//Game TODO: Enter the game
}
else if (loginRet.flag == eFlag_NeedRealNameAuth)
{
//It is needed to carry out real-name authentication. The business itself can set real-name authentication workflow. Configure MSDK_REAL_NAME_AUTH_SWITCH in info.plist; default: 0
//0, the business does not need to perform any operation and just stays in the login page. MSDK automatically pops up real-name registration page to guide the user to register. After the registration is completed, the user will be guided to login again.
//1, the business does not need to perform any operation and just stays in the login page. MSDK automatically pops up real-name registration page to guide the user to register. The business needs to monitor the login callback again. After the real-name registration succeeds, MSDK will automatically call the local token login interface for automatic login
//2, the business itself defines the real-name authentication UI and realizes the real-name authentication workflow
//User-defined UI certification workflow
//1 Pop up the real-name authentication UI to facilitate the user to fill out relevant information
//2 Call WGSetRealNameAuthObserver interface to set real-name authentication callback
//3 Call MSDK’s real-name authentication interface for certification, and wait f
//4 Handle OnRealNameAuthNotify callback
}
else
{
//Login failed
//Game TODO: Remind the player of relevant information according to flag
}
}
Callback for the platform launching a game
When a game is launched in mobile QQ and WeChat, it will call this callback, which contains the launched account, the data passthrough by the platform and other information. For detailed settings, refer to the login module’s Account inconsistency handling.
Demo code:
void MyObserver::OnWakeupNotify(WakeupRet& wakeupRet)
{
switch (wakeupRet.flag)
{
case eFlag_Succ:
//After local account login succeeds, the player can directly enter the game; the platform call also the automatic login interface WGLogin() but need to wait for login callback
break;
case eFlag_NeedLogin:
//In case of no valid token, logout of the game to let the user re-login
break;
case eFlag_UrlLogin:
//There is no account information in the local. In this case, the platform can automatically login the game with the launched account but need to wait for login callback
break;
case eFlag_NeedSelectAccount:
//Pop up a prompt box to let the user to select a login account, and call WGSwitchUser interface according to the user's choice
break;
case eFlag_AccountRefresh:
//the external account is the same as the login account; use the external token to update the local token, and need to wait for login callback
break;
default:
break;
}
}
Switch Configuration Interface
MSDK 3.3.22 version starts to add switch configuration interface. After the user agrees to the terms of the user agreement, the game can call this interface to enable MSDK and the third-party components included in MSDK to obtain relevant information; MSDK will not obtain relevant information before the switch is enabled.
Interface declaration
c++:
/*
* Set whether to allow obtaining relevant information
*/
void WGSetCouldCollectSensitiveInfo(bool couldCollect);
Warning:
- The user must actively call the interface after agreeing to the relevant terms of the agreement.
- 【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".
Information field setting interface
Starting from version 3.3.28, MSDK has added a new interface for setting information fields. Apps can obtain relevant information fields themselves and then invoke this interface to set the fields to MSDK and third-party components included in MSDK (currently supported by Beacon components)
Interface example
MSDKSensitive::SetSensitiveInfo("{\"WiFiMacAddress\":\"xxx\", \"WiFiName\":\"xxx\", \"Idfa\":\"xxx\"}");
Warning:
- Beacon iOS currently supports WiFiMacAddress, WiFiName and Idfa fields.
MSDK iOS permission list
Channel | Required permission | Optional permission | Purpose of use |
---|---|---|---|
MSDK | 1、Network permissions | 2、Location information | 1、Network connection 2、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 |
3、Camera permissions | 3、Can visit the camera in the webpage. If your game doesn't require this function, you don't need to configure this permission | ||
4、User tracking (NSUserTrackingUsageDescription) | 4、Get the IDFA of users of iOS14.5 and higher versions for data analysis and advertising purchase statistics | ||
1、Network permissions | 1、Network communication | ||
- | - | - | |
Bugly | 1、Network permissions | 1、Network communication | |
QIMEI | 1、Network permissions | 1、Network communication | |
Beacon | 1、Network permissions | 1、Data reporting | |
TPNS | 1、APNS (push) | 1、Allow the program to use APNS services | |
2、Network permissions | 2、Allow the program to connect |
FAQ
Instructions on the adaption of WeChat OpenSDK to iOS 15 system
For Apps compiled with Xcode13.0 and higher versions, the number of URL Scheme query
is limited to 50 in iOS 15.0 and higher systems. For Apps with more than 50 schemes configured in LSApplicationQueriesSchemes
in plist
, they may cause:
- Some interfaces of WeChat OpenSDK return wrong results;
- Unable to use
Universal Link
to initiate WeChat, causing the problem that App's name is added with "Unverified Application" after messages are shared to WeChat.
Developers who use Xcode 13.0 and above versions to compile App need to adapt to iOS 15 to ensure the normal use of WeChat OpenSDK.
Background
Starting from iOS 9, iOS has supported configuring LSApplicationQueriesSchemes
in the project's plist
.
After configuring the scheme of other Apps in LSApplicationQueriesScheme
, you can use the following code to judge whether or not to skip to the corresponding App through scheme.
BOOL ret = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"weixin://"]];
When WeChat OpenSDK is accessed,WeChat Access Documentation requires to add "weixin" and "weixinULAPI" in LSApplicationQueriesScheme.
iOS 15 system-related changes
Confirmed with Apple, **On iOS 15 system, for Apps compiled with Xcode 13, the number ofLSApplicationQueriesSchemes shall be limited to 50.
The scheme configuration after the 50th scheme will not take effect. The following code will return NO
BOOL ret = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"otherAppScheme://"]];
Suggestions on adaptation to WeChat OpenSDK
If the number of schemes configured in LSApplicationQueriesSchemes
is less than 50 or the two schemes, "weixin" and "weixinULAPI", are in the first 50 ones, it is not needed to adapt to WeChat OpenSDK.
Apps compiled with Xcode 12 and lower versions currently do not need to adapt to WeChat OpenSDK.
Make sure that "weixin" and "weixinULAPI" are configured in the first 50 of LSApplicationQueriesSchemes. Otherwise, the following interfaces may return incorrect results or behave abnormally in the iOS 15 system:
[WXApi isWXAppInstalled]
:it will also return "NO" if WeChat is installed[WXApi isWXAppSupportApi]
:it will also return "NO" if it is supported[WXApi isWXAppSupportStateAPI]
:it will also return "NO" if it is supported[WXApi sendAuthReq:viewController:delegatecompletion]
:it will judge whether WeChat is installed and will then initiate the webpage authorization.- All interfaces will not be able to use
Universal Link
to initiate WeChat and will use scheme to initiate WeChat in a downgrading manner, resulting in the "Unverified Application" problem