微博 A ( 控制台,统计 )

本文介绍如何在iOS应用中集成新浪微博SDK,实现分享和登录功能。通过详细步骤展示了如何配置项目,注册活跃平台,设置应用信息,并启用加密传输和日志记录。

#import “ViewController.h”
//新浪微博SDK头文件
#import “WeiboSDK.h”
//新浪微博SDK需要在项目Build Settings中的Other Linker Flags添加"-ObjC"

#import <ShareSDK/ShareSDK.h>
#import <ShareSDKConnector/ShareSDKConnector.h>

#import <UMCommon/UMCommon.h>

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ViewController *vie=[[ViewController alloc] init];
    UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:vie];
    self.window.rootViewController=nav;

//在友盟统计控制台,添加登录界面统计和邀请好友按钮点击事件的统计
[UMConfigure initWithAppkey:@“5ba1be04b465f5a258000073” channel:nil];
[UMConfigure setEncryptEnabled:YES];//打开加密传输
[UMConfigure setLogEnabled:YES];//设置打开日志

/**初始化ShareSDK应用
 
 @param activePlatforms
 
 使用的分享平台集合
 
 @param importHandler (onImport)
 
 导入回调处理,当某个平台的功能需要依赖原平台提供的SDK支持时,需要在此方法中对原平台SDK进行导入操作
 
 @param configurationHandler (onConfiguration)
 
 配置回调处理,在此方法中根据设置的platformType来填充应用配置信息
 
 */

[ShareSDK registerActivePlatforms:@[
                                    @(SSDKPlatformTypeSinaWeibo)
                                    ]
                         onImport:^(SSDKPlatformType platformType)
 {
     switch (platformType)
     {
         
         case SSDKPlatformTypeSinaWeibo:
             [ShareSDKConnector connectWeibo:[WeiboSDK class]];
             break;
         
         default:
             break;
     }
 }
                  onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo)
 {
     
     switch (platformType)
     {
         case SSDKPlatformTypeSinaWeibo:
             //设置新浪微博应用信息,其中authType设置为使用SSO+Web形式授权
             [appInfo SSDKSetupSinaWeiboByAppKey:@"568898243"
                                       appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"
                                     redirectUri:@"http://www.sharesdk.cn"
                                        authType:SSDKAuthTypeBoth];
             break;
         
         default:
             break;
     }
 }];
return YES;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值