New user guide for WeChat iOS terminal SDK

Source: Internet
Author: User
Note: This document is a new tutorial for iOS terminal SDK. it only involves how to use the SDK. by default, readers are familiar with the basic usage of XCode development tools, and a certain degree of programming knowledge.

Note: This document is a new tutorial for iOS terminal SDK. it only involves how to use the SDK. by default, readers are familiar with the basic usage of XCode development tools, and a certain degree of programming knowledge.

1. Register your application id

Go to the developer application registration page to register. after you register and select a mobile application for configuration, you will obtain the AppID, which can be used for development immediately. However, after the application registration is completed, it must be submitted for review. only applications that have passed the review can be officially released for use.

2. download the terminal SDK file

The SDK file contains libWeChatSDK. a, WXApi. h, and WXApiObject. h.

Download: iOS platform development kit

3. build a development environment

[1] create your project in XCode.

[2] Upload The libWeChatSDK contained in the SDK file. a, WXApi. h, WXApiObject. h. add the three files to the project you created (as shown in, create a project named Test and add the three files to the Test folder ).

(Note: If XCode 4.3 or earlier is used, use libWeChatSDK. a. If XCode 4.5 or later is used, use libWeChatSDK_armv7_v7s.a)


[3] Select Build Setting in your project file, and add libWeChatSDK. a, WXApi. h, and WXApiObject. h to the Search Paths file (as shown in ).

(Note: If XCode 4.3 or earlier is used, use libWeChatSDK. a. If XCode 4.5 or later is used, use libWeChatSDK_armv7_v7s.a)


[4] in Xcode4, select your project settings and select the "TARGETS" column, add "URL scheme" in "URL type" in the "info" tab to the application id you have registered. If you are using Xcode3 or a later version, you must add it to the plist file, as shown in ).

Xcode4 set URL scheme

[5] import the WXApi. h header file in the file you want to use the terminal API, and add the WXApiDelegate protocol.

4. use the development kit in the code

[1] to enable the terminal to respond to your program after your program starts, you must register your id with the terminal in the code. (As shown in, register the id in the didFinishLaunchingWithOptions function of AppDelegate ).

[2] Rewrite the handleOpenURL and openURL methods of AppDelegate:

[3] now, to implement specific requests and responses for interaction with terminals, you need to implement the WXApiDelegate protocol in two ways:

-(Void) onReq :( BaseReq *) reqonReq is a request initiated by a terminal to a third-party program and requires a third-party program to respond. The third-party program must call sendRsp to return the response. When sendRsp is called to return, it is switched back to the terminal program interface. /-(Void) onResp :( BaseResp *) resp if a third-party program sends a sendReq request, the onResp will be called back. After the sendReq request is called, it is switched to the terminal program interface. The content to be completed in these two methods is defined by you. for details, refer to the SDK Sample Demo source code in the development kit.


[4] if your program needs to send a message, you need to call the sendReq function of WXApi:

-(BOOL) sendReq :( BaseReq *) req where the req parameter is of the SendMessageToWXReq type.

Note that if the scene member of SendMessageToWXReq is set to WXSceneSession, the message is sent to the session. If the scene field is WXSceneTimeline (4.2 or later, if you need to check the version support API, you can call [WXApi getwxappsuppmaxapiversion], and SDK1.1 or later supports sending the circle of friends), the message will be sent to the circle. The default value of scene is WXSceneSession.


Now, you can use the terminal sdk api content. For more details about the usage of each API function, refer to the API documentation on the official website or download and read the SDK Sample Demo source code.

SDK Sample Demo source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.