Open Platform: WeChat for iOS

Source: Internet
Author: User
Tags sendmsg

For example, first list some URLs:

Open Platform home: http://open.weixin.qq.com

Ios sdk official: http://open.weixin.qq.com/download/sdk/wechat_sdk_ios.zip

Share friends API call official use of tutorials: http://open.weixin.qq.com/document/gettingstart/ios? Lang = zh_cn

Currently, the open platform provides two APIs:

1: share information with friends

2: Share information directly to the circle of friends

In fact, the official tutorials are very detailed. I also follow the official steps to implement them,

So why write this tutorial? The main purpose is to reduce unnecessary time overhead and some blind spots mentioned in the official tutorials.

Start:

There are five steps to share data with friends. Note: Do not confuse the order:

1: AddURL type"URL Scheme"ID of the application you registered, which is appid

2: Introduce the header file and declare the delegate to be implemented at the interface.

3: register the applied appid. If this method is not called, the client cannot be started.

[WXApi registerApp:WeiXinAppID]

4. Implement the following delegate in appdelegate to receive the callback response from the client:

-(Bool) Application :( uiapplication *) Application Openurl :( nsurl *) URL sourceapplication :( nsstring *) sourceapplication annotation :( ID) annotation {// if other application interactions are involved, make the following judgment, for example, if ([url. scheme isequaltostring: weixinappid]) {return [wxapi handleopenurl: URL delegate: Self];} else {return yes ;}}

5. Call the following methods and parameters to immediately display the client

SendMessageToWXReq *sendMsg = [[SendMessageToWXReq alloc] init];sendMsg.text =  @"123";sendMsg.bText = YES;[WXApi sendReq:sendMsg];

6: when the interface return button is clicked, the client will call back to enable its own application.UiapplicationdelegateProxy, that is, the fourth point.

When executed[Wxapi handleopenurl: URL delegate: Self]The API delegate will be triggered later:

-(void)onResp:(BaseResp *)resp{    NSLog(@"%@",resp);    NSLog(@"errStr %@",[resp errStr]);    NSLog(@"errCode %d",[resp errCode]);    NSLog(@"type %d",[resp type]);}

Since then, the interaction between the entire application and the client has ended.

Date:

If the SDK is used in a workspace and configured in the other linker flags file of the project configuration file-All_load 

In this case, a compilation error occurs during compilation on the real machine, and you do not know what file is wrong. In this case, do not use-All_loadYes, use-Force_load

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.