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