Sharing and email sharing
Reference URL:
Http://www.jianshu.com/p/7a2f49c654df
1. Apply for APPKey
2. sample code in the AppDelegate. m file
# Import "AppDelegate. h "# import" WXApi. h "@ interface AppDelegate () @ end @ implementation AppDelegate-(BOOL) application :( UIApplication *) application didFinishLaunchingWithOptions :( NSDictionary *) launchOptions {[WXApi registerApp: @ "applied APPkey"]; return YES ;}
3. Implementation of specific methods
# Import "ViewController. h "# import" WXApi. h "@ interface ViewController () @ property (nonatomic, strong) UIButton * button; @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; self. button = [[UIButton alloc] initWithFrame: CGRectMake (100, 50,100, 50)]; self. button. backgroundColor = [UIColor blueColor]; [self. button addTarget: self action: @ selector (buttonClick :) forControlEvents: UIControlEventTouchUpInside]; [self. view addSubview: self. button];}-(void) buttonClick :( UIButton *) button {NSLog (@ "click "); // create the sending object instance SendMessageToWXReq * sendReq = [[SendMessageToWXReq alloc] init]; sendReq. bText = NO; // do not use text information sendReq. scene = 0; // 0 = friend list 1 = friend list 2 = favorites // create a shared Content Object WXMediaMessage * urlMessage = [WXMediaMessage message]; urlMessage. title = @ ""; // share the subject urlMessage. description = @ ""; // share the description [urlMessage setThumbImage: [UIImage imageNamed: @ "test"]; // share the image, use the SDK setThumbImage method to compress the image size. // create a multimedia object WXWebpageObject * webObj = [WXWebpageObject object]; webObj. webpageUrl = @ "https://www.baidu.com"; // share link // complete sending object instance urlMessage. mediaObject = webObj; sendReq. message = urlMessage; // sends the shared message [WXApi sendReq: sendReq];}