Share iOS WeChat and iOS emails

Source: Internet
Author: User

IOS sharing and iOS email sharing

1. register an open platform account: https://open.weixin.qq.com

2. Create an application

Setting pictures can use a gadgets, details http://www.cnblogs.com/czq1989/p/5073586.html

Generally, it takes several hours to review the application. After the application is approved, the application can be deleted.

3. Download the SDK

4. Build a Development Environment

Import files in the Development Kit

Import the dependency library, which is officially required to import four

SystemConfiguration. framework

Libz. tbd

Libsqlite3.0.tbd

Libc ++. tbd

Configure url type

5. Write related Code

In AppDelegate. m

Note that the two methods to be rewritten do not need to be used now. Just adapt to the earlier version.

Import WXApi. h

1 #import "WXApi.h"

Comply with WXApiDelegate Protocol

1 @interface AppDelegate ()<WXApiDelegate>

 

Register the App in the didfinishlaunchingwitexceptions Method

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    [WXApi registerApp:@"################"];    return YES;}

 

Two methods to override appdelegate

1 - (BOOL) application:(UIApplication *)application handleOpenURL:(NSURL *)url {2     return [WXApi handleOpenURL:url delegate:self];3 }

 

1 - (BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {2     return [WXApi handleOpenURL:url delegate:self];3 }

 

In ViewController. m, create a button and click Finish sharing.

1 # import "ViewController. h "2 # import" WXApi. h "3 4 @ interface ViewController () <WXApiDelegate> 5 6 @ end 7 8 @ implementation ViewController 9 10-(void) viewDidLoad {11 [super viewDidLoad]; 12 [self setButton]; 13 // Do any additional setup after loading the view, typically from a nib.14} 15 16-(void) setButton {17 UIButton * button = [UIButton buttonWithType: UIButtonTypeCustom]; 18 [button setFrame: CGRectMake (120,120,120, 36)]; 19 [button setTitle: @ "SharingTest" forState: UIControlStateNormal]; 20 [button setTitleColor: [UIColor blackColor] forState: UIControlStateNormal]; 21 [self. view addSubview: button]; 22 [button addTarget: self action: @ selector (sendMessage) forControlEvents: UIControlEventTouchUpInside]; 23} 24 25-(void) sendMessage {26 SendMessageToWXReq * req = [[SendMessageToWXReq alloc] init]; 27 req. text = @ "TigerCui Test message, ignore"; 28 req. bText = YES; 29 req. scene = WXSceneSession; 30 [WXApi sendReq: req]; 31}

 

6. Minor problems encountered in the middle

 

Demo: https://github.com/TigerCui/WeChatSharingDemo.git

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.