IOS 集成友盟分享

Posted 守望星空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 集成友盟分享的主要内容,如果未能解决你的问题,请参考以下文章

友盟分享小结 - iOS

ios开发之--友盟开发的使用

友盟分享适配iOS9

Android集成友盟社会化分享功能

iOS小技能: 社会化分享

友盟的常见使用----三方登陆分享和“埋点”(友盟统计)