首页 > 代码库 > IOS 集成友盟分享

IOS 集成友盟分享

#import <Foundation/Foundation.h>

@interface UMSocialSinaHandler : NSObject

+(void)openSSOWithRedirectURL:(NSString *)redirectURL;

@end

 

#import "AppDelegate.h"
#import "UMSocial.h"
  #import "UMSocialSinaHandler.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    // 设置友盟分享的秘钥
     [UMSocialData setAppKey:@"5458264dfd98c5b5c9007064"];
    
    //打开新浪微博的SSO开关,设置新浪微博回调地址,这里必须要和你在新浪微博后台设置的回调地址一致。若在新浪后台设置我们的回调地址,“http://sns.whalecloud.com/sina2/callback”,这里可以传nil
    [UMSocialSinaHandler openSSOWithRedirectURL:@"http://sns.whalecloud.com/sina2/callback"];
    
    return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return  [UMSocialSnsService handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation
{
    return  [UMSocialSnsService handleOpenURL:url];
}

@end

 

#import "ViewController.h"
#import "UMSocial.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    //注意:分享到微信好友、微信朋友圈、微信收藏、QQ空间、QQ好友、来往好友、来往朋友圈、易信好友、易信朋友圈、Facebook、Twitter、Instagram等平台需要参考各自的集成方法
    /*
     SheetView: 需要在哪个视图中展示
     appKey: 当前应用的友盟分享的key
     shareText: 需要分享的文本
     shareImage: 需要分享的图片
     shareToSnsNames: 需要分享到的平台
     */
    /*
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"5458264dfd98c5b5c9007064"
                                      shareText:@"你要分享的文字"
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren, UMShareToDouban, UMShareToFacebook, UMShareToFlickr, UMShareToInstagram, nil]
                                       delegate:nil];
     */
    
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"5458264dfd98c5b5c9007064"
                                      shareText:@"友盟社会化分享让您快速实现分享等社会化功能,www.umeng.com/social"
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:@[UMShareToSina]
                                       delegate:self];
}
@end

 

 

IOS 集成友盟分享