WeChat sharing and email sharing

Source: Internet
Author: User

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];}

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.