Detailed process of WeChat access is shared with friends and circle of friends.

Source: Internet
Author: User

Detailed access process sharing with friends and circle of friends

 

0. First create an application address https://open.weixin.qq.com at the open platform Registration

Create an application and submit materials in the Management Center. for review, make sure that the Bundle ID is correct.

The AppID and AppSecret obtained after the review is completed may take about one week.

1. SDK https://open.weixin.qq.com/cgi-bin/showdocument? Action = dir_list & t = resource/res_list & verify = 1 & id = open1419319164 & lang = zh_CN

Select the databases and files required to use the sharing, login, favorites, and payment functions. Click to download the 64-bit iOS SDK

2. open the file after the download is complete. Four files are required.

LibWeChatSDK. a, WechatAuthSDK. h, WXApi. h, WXApiObject. h

Put the four files in a folder and drag them into your project.

3. Click the blue project name-> Build Phases-> the third line Link Binary to add the corresponding Library

Figure 1

4. Click the blue project name-> Build Setting-> Search for Search Paths on the right.

Double-click "open" in the Library Search Paths and click "$ (SRCROOT)/Test/SDK1.6.2" in the lower left corner + Add SDK path"

The project named "Test" is to drag the folder "SDK1.6.2" to the project directory. Note that this path must be correct.

5. Add the URL type for your project.

Figure 2

The added URL Types URL Schemes column must be filled with the AppID of the application we applied on the open platform.

 

6. import the header file # import "WXApi. h" in the project's AppDelegate. h file and follow the proxy method

The AppDelegate. h file is changed

# Import <UIKit/UIKit. h>

# Import <CoreData/CoreData. h>

# Import "WXApi. h"

@ Interface AppDelegate: UIResponder <UIApplicationDelegate, WXApiDelegate>

 

@ Property (strong, nonatomic) UIWindow * window;

@ End

 

 

7. In this method in the AppDelegate. m file, register WXAppID as the AppID obtained by the open platform.

-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {

 

// Register

[WXApi registerApp: WXAppID];

 

}

 

 

Then rewrite the two methods in the AppDelegate. m file.

/**

* Interface Rewriting Method

*

* @ Param application <# application description #>

* @ Param url <# url description #>

*

* @ Return <# return value description #>

*/

-(BOOL) application :( UIApplication *) application handleOpenURL :( NSURL *) url

{

Return [WXApi handleOpenURL: url delegate: self];

}

/**

* Interface Rewriting Method

*

* @ Param application <# application description #>

* @ Param url <# url description #>

* @ Param sourceApplication <# sourceApplication description #>

* @ Param annotation <# annotation description #>

*

* @ Return <# return value description #>

*/

-(BOOL) application :( UIApplication *) application openURL :( NSURL *) url sourceApplication :( NSString *) sourceApplication annotation :( id) annotation

{

Return [WXApi handleOpenURL: url delegate: self];

}

 

 

8. then import the header file in the. m file where you need to share it and follow the proxy

# Import "WXApi. h"

<WXApiDelegate>

If there is a button, click to share

 

Implementation click Method

 

View plaincopy

 

 

Note that you must share it on a real machine.

The SendMessageToWXReq class can only share text. You need to find the corresponding class.

 

Here, req. scene refers to what to share

WXSceneSession = 0,/** <chat interface */

WXSceneTimeline = 1,/** <circle of friends */

WXSceneFavorite = 2,/** <favorites */

 

Select a place to share as needed

Now, go to the real machine and try it out.

 

Related Article

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.