1. 程式人生 > >IOS 集成友盟分享

IOS 集成友盟分享

med lin back implement sina 註意 cal clas soc

#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 集成友盟分享