iOS自带的Social.framework 自带的社交分享SDK

n很多App中都有个“社交分享”的功能 

p通过用户的分享,让更多的人去了解和使用这个App 

p目前移动互联网应用程序推广的最重要手段之一 

p属于口碑营销的范畴,经典成功案例是疯狂猜图 

n比较火的分享平台 

p微信  是国内唯一一款没有PC原型的软件 

p新浪微博  苹果在iOS 6集成了 

p腾讯微博  iOS 7集成的


niOS中,实现“社交分享”的方法 

p自己编写各个平台的分享代码(代码量较多) 

p利用iOS自带的Social.framework

p利用第三方的分享框架 ü友盟分享:http://dev.umeng.com/social/ios/share/quick-integration üShareSDKhttp://wiki.mob.com/iOS快速集成指南 ü百度社会化分享组件:http://developer.baidu.com/soc/share

百度还有个“社会化登录组件”:http://developer.baidu.com/soc/login



Social.framework支持的分享平台(打开手机上的“设置”即可看到)

iOS自带的Social.framework 自带的社交分享SDK_第1张图片

点击进入进行设置:(进行登录)

iOS自带的Social.framework 自带的社交分享SDK_第2张图片


然后通过代码进行分享:(先导入#import <Social/Social.h>)

//
//  ViewController.m
//  01-系统自带分享
//

//

#import "ViewController.h"
#import <Social/Social.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // 1.判断平台是否可用
    if (![SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) {
        NSLog(@"查看您是否设置了新浪微博帐号,设置界面-->新浪微博-->配置帐号");
    }
    
    // 2.创建SLComposeViewController
    SLComposeViewController *composeVc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeSinaWeibo];
    
    // 2.1.添加分享文字
    [composeVc setInitialText:@"做人如果没有梦想,跟咸鱼有什么区别"];
    
    // 2.2.添加分享图片
    [composeVc addImage:[UIImage imageNamed:@"xingxing"]];
    
    // 3.弹出分享界面
    [self presentViewController:composeVc animated:YES completion:nil];
    
    
    // 4.设置block属性
    composeVc.completionHandler = ^ (SLComposeViewControllerResult result) {
        if (result == SLComposeViewControllerResultCancelled) {
            NSLog(@"用户点击了取消");
        } else {
            NSLog(@"用户点击了发送");
        }
    };
}

@end

点击出现下方的界面

iOS自带的Social.framework 自带的社交分享SDK_第3张图片




你可能感兴趣的:(分享,社交)