notes 1: For access openSDK For developers of openSDK Privacy data usage, can refer to document< WeChat > iOS openSDK Privacy data usage >。
# Update notes for open SDK 1. 8. 6 and above
Thanks to Apple iOS System version security upgrade, for which the open SDK adapts to version 1. 8. 6 and above. 1.8.6 and above support for Universal Links way jump, to open SDK share legitimacy verification.
*Suggest developers access the new version of the SDK, Test WeChat 7.0.7 or above, iOS 12 or 13 to verify the functionality and usability of the interface used.
# catalog
- SDK Access Success Verification Guidelines
- SDK Access Guidelines
- Troubleshoot access problems using SDK self-check function
# SDK Access Success Verification Guidelines
# Environment
SDK version: SDK 1. 8. 6 or above
WeChat version: 7.0.7 or above
System Version: IOS 12 or above
# 1. Confirm WeChat's Universal Link normal
First of all, confirm WeChat(7.0.7 or above) Links works fine on devices to ensure open SDK and WeChat use Universal in both directions Link Communications
Safari input
https://help.wechat.with/app/
Drop down to see if you have opened the WeChat entry(Below). If there is no entrance, it may be due to the system pulling WeChat Universal Links failed, please check the phone network status is normal, or update/Reloaded WeChat
# 2. Confirm App Of Universal Link configured successfully
WeChat uses third-party app Universal When Links evokes third-party apps, it will be at Universal Links ends with stitching paths and parameters, so developer Universal The link configuration must be accompanied bywildcard characterAnd test Universal. Can Link Splice String Evoke App
Recommendation Universal Links configure path, for example/app/*, Avoid a Universal Hit Link jump
SDK Sample configuration as an example:
{ "appID": "teamID.with.tencent.ask.SDKSample", "paths": ["/sdksample/*"] }
Test the configuration for success:
1) Safari Input Universal Links(Include full path) + random string(For example: abc)
SDK Sample的Universal Links:
https://help.wechat.with/sdksample/
Universal Test Input Safari Links:
https://help.wechat.with/sdksample/abc
2) Drop-down page to check if there is an entry prompt to open the app((below)
# 3. Continuously initiate sharing and confirm that it will not happen for many times.
When users start sharing with the new version of the SDK for the first time, the following interactive process will appear: pull up WeChat from the App - appear "Connecting" page - return to the app - re-open WeChat. Above is the new security verification process, each user will be the first time to use the jump. (As a user may jump when using Share for many times, please follow the following access guidelines to check Universal. Link configuration)
# 4. If App has WeChat authorized login function, confirm authorization does not appear secondary confirmation pop-up window
Authorized login such as the following secondary confirmation pop-up window, because WeChat can not provide Universal via App Links returns resulting in, most likely, App Universal Links are not valid, please check Universal according to the access guidelines Links configuration
# SDK Access Guidelines
*Please note that the red part of the configuration
# 1. Universal for configuring applications Links
1) Based Apple Files Configure Universal for Your Application Links
WeChat vs Universal Links Configuration requirements
a)Universal Links must support https
b)Universal Links configured paths cannot take query parameter
C) WeChat using Universal When Links pulls up a third-party app, it will be at Universal Links splices paths and parameters at the end of the link, so App configured paths must have wildcards/*
Example:
{
"appID": "8P7343TG54.with.tencent.ask.SDKSample",
"paths": ["/sdksample/*"]
}
**2) Open Associates Domains switch, will Universal Links Domain names added to the configuration **
3) Check to confirm the app's Universal Links configured successfully with the aboveSDK Access Success Verification Guidelines operation
# 2. Register your app ID with WeChatAnd Universal Links
Please come Developer Application Registration Page After registering and selecting the mobile app to set up, you get an AppID that can be used immediately for development. However, applications need to be submitted for review after the completion of registration, and only approved applications can be officially released.
# 3. Download WeChat Terminal SDK file
SDK Documents include libWeChatSDK.a,WXApi.h,WXApiObject.h Three. For manual integration, please go toResource Download Page SDK package
# 4. Building the development environment
# 4.1 adopt CocoaPods integrated
[1] in XCode Build your project in.
[2] In engineering Podfile Add the following code inside:
under 'WechatOpenSDK'
Save and execute under Install, followed by the suffix. xcworkspace Open the file works.
Attention:
Execute from the command line under search The Wechat Open SDK, as shown WechatOpenSDK If the version is not current, execute under repo update Operation update local repo Content
about CocoaPods For more information, please see CocoaPods Official website 。
[3] in Xcode In the "info" tab, select your project settings, select the "PROJECTS" column, and click "URL" Type "Add" URL scheme” The application registered for you Id (shown below).
Xcode Set up URL scheme
[4] In Xcode, select your project settings item, select the "PROJECTS" column, and "LSApplicationQueries Schemes" in the "info" tab bar Add wechat And weixin ULAPI (shown below).
Verified in iOS 15 system, using Xcode The number of compiled Apps, LSApplicationQueries Schemes will be limited to 50. Scheme configurations after the 50th will not take effect and you need to make sure that the "wicat" and "weixin ULAPI" configurations are in the first 50 of the LSApplicationQueries Schemes.
[5] Before you need to make Use WeChat Terminals API In the file import WXApi.h Header file, and add WXApiDelegate Protocol.
#import <UIKit/UIKit.h>
#import "WXApi.h"
@interface AppDelegate : UIResponder<UIApplicationDelegate, WXApiDelegate>
@property (strong, nonatomic) UIWindow *window
@end
3.2 Manual integration
[1] in XCode Build your project in.
[2] will SDK Contained in the file libWeChatSDK.a,WXApi.h,WXApiObject.h Three files are added to the project you built (as shown below) to create a file called Test And add the above three files to Test Folder under).
(Note: Please use xCode4.5 And above)
[3]Developers need to link in the project: Security.framework, CoreGraphics.framework, WebKit.framework。
[4] Select from your project file Build Setting, in " Other Linker Flags "Join in" - ObjC -all_load " In. Search Paths Add libWeChatSDK.a , WXApi.h, WxApiObject.h, where the file is (as shown below).
(Note: Please use xCode4.5 And above)
[5] in Xcode In the "info" tab, select your project settings, select the "PROJECTS" column, and click "URL" Type "Add" URL scheme” The application registered for you Id (shown below).
Xcode Set up URL scheme
[6] In Xcode, select your project settings item, select the "PROJECTS" column, and "LSApplicationQueries Schemes" in the "info" tab bar Add wechat And weixin ULAPI (shown below).
[7] Before you need to make Use WeChat Terminals API In the file import WXApi.h Header file, and add WXApiDelegate Protocol.
#import <UIKit/UIKit.h>
#import "WXApi.h"
@interface AppDelegate : UIResponder<UIApplicationDelegate, WXApiDelegate>
@property (strong, nonatomic) UIWindow *window
@end
# 5. Using development kits in your code
[1] In order for your app to be able to respond to your app, you must register your app with the WeChat app in the code. id。 As shown in the figure below, in the AppDelegate of didFinishLaunchingWithOptions Function in the WeChat registration id)。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Register with WeChat
[WXApi registerApp:APP_ID
universalLink:UNIVERSAL_LINK]
return YES
}
[2] Rewrite AppDelegate of handleOpenURL and openURL Methodology:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [WXApi handleOpenURL:url delegate:self]
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [WXApi handleOpenURL:url delegate:self]
}
**[3] Rewrite AppDelegate Or SceneDelegate Of continueUserActivity Methods: ** Note: The application that adapts to SceneDelegate will call back the continuueUserActivity method of Scene Delegate, so this method needs to be overridden.
AppDelegate:
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void()(NSArray<id<UIUserActivityRest
oring>> * __nullable restorableObjects))restorationHandler {
return [WXApi handleOpenUniversalLink:userActivity delegate:self]
}
SceneDelegate:
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
[WXApi handleOpenUniversalLink:userActivity delegate:self]
}
[4] Now, your program needs to implement specific requests and responses to interact with WeChat terminals, so you need to implement WXApiDelegate Two approaches to the protocol:
-(void) onReq:(BaseReq*)reqonReq
It is the WeChat terminal to initiate a request to a third-party program and request a response from the third-party program. The third-party program must call the sendRsp Return. In calling sendRsp When returned, it will cut back to the WeChat terminal program interface.
-(void) onResp:(BaseResp*)resp.
If a third-party application sends a message to WeChat sendReq Of the United States, then. onResp Will be called back. sendReq Request call, will cut to the WeChat terminal program interface.
You can define what you want to accomplish in these two methods. For details, please refer to the SDK Sample Demo Source code.
[5] If your program wants to send a message to WeChat, then you need to call WXApi of sendReq Function:
+ (void)sendReq:(BaseReq *)req completion:(void (
__nullable)(BOOL success))completion
among req Parameter is SendMessageToWXReq Type.
Note that SendMessageToWXReq of scene Member, if scene fill WX Scene Session, then the message will be sent to the WeChat session. if scene fill WX Scene Timeline, then the message will be sent to the circle of friends. if scene fill WXSceneFavorite, then the message is sent to My Collection. scene Default value is WXSceneSession。
So far, you can use the WeChat terminal SDK of API Content. If you want to know more about each API Function usage, please refer to the official website API Document or download to readWeChat SDK Sample Demo source code。
# Using the SDK Self-checking function troubleshooting access problems
SDK1.8.7Version, WXApi added a self-checking functioncheckUniversalLinkReady:
To help developers troubleshoot SDK access problems.
# Using the SDK Self-checking function troubleshooting access problems
SDK1.8.7Version, WXApi added a self-checking functioncheckUniversalLinkReady:
To help developers troubleshoot SDK access problems.
Notes:
- The registerApp: universalLink interface must be called before calling the self-check function, And confirm that the call was successful.
- There will be a Log generated in the self-check process, you can first call startLogByLevel function, according to Log troubleshooting problems
- Multiple callbacks to block
- Only for new access to the SDK debugging use, do not call in the formal environment
Sample code:
//Open log before register, The follow-up can be based on the log to troubleshoot problems
[WXApi startLogByLevel:WXLogLevelDetail logBlock:(NSString *log) {
NSLog(@ " WeChatSDK: %@", log)
}]
Sample code:
```Objective-C
//Open log before register, The follow-up can be based on the log to troubleshoot problems
[WXApi startLogByLevel:WXLogLevelDetail logBlock:(NSString *log) {
NSLog(@ " WeChatSDK: %@", log)
}]
//Be sure to register before calling the self-check function
[WXApi registerApp:APP_ID universalLink:UNIVERSAL_LINK]
//Call Self Checking Function
[WXApi checkUniversalLinkReady:(WXULCheckStep step, WXCheckULStepResult* result) {
NSLog(@"%@, %u, %@, %@", @(step), result.success, Result.errorInfo, result.suggestion)
}]
WXUL CheckStep Value Dxplaination:
- step =
WXULCheckStepParams
: Parameter checking - step =
WXULCheckStepSystemVersion
: Current System Version Check - step =
WXULCheckStepWechatVersion
: WeChat client version check - step =
WXULCheckStepSDKInnerOperation
: WeChat SDK internal operation check - step =
WXULCheckStepLaunchMoach
: App pull up WeChat check - step =
WXULCheckStepBackToCurrentApp
: Check the current app by WeChat - step =
WXULCheckStepFinal
: Final inspection
Will call back the seven steps in turn, when the callbackWXULCheckStepFinal
, indicating that the test passed, SDK access success.
For any step callbackresult.success
For NO, Process terminates, no subsequent callbacks can be made byResult.errorInfo
To view the cause of the current step error, according to theresult.suggestion
Fix the problem.