Skip to content

客户端分享(新浪微博分享,QQ分享,QQ空间分享,微信好友分享,微信朋友圈分享与登录)

Notifications You must be signed in to change notification settings

chenyun120/CYShare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

 第一步:
 
 在AppDelegate.m中:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

	// 分享配置
	[self setShared];

	return YES;
}

- (void)setShared
{
	ALIAS( [SinaWeibo sharedInstance], singan );
	ALIAS( [WXChatShared sharedInstance], wxchat );
	ALIAS( [TencentOpenShared sharedInstance], tencent );

	// 新浪微博分享
	singan.appKey = @"2716041576";
	[singan powerOn];

	// 微信分享
	wxchat.appId = @"wx67389d6a38a4bf60";
	[wxchat powerOn];

	// QQ分享
	tencent.appId = @"101027797";
	[tencent powerOn];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
	// 发送通知
	if ( url || sourceApplication )
	{
		NSDictionary * params = @{@"url" : url,
								  @"source" : sourceApplication
								 };
		[[NSNotificationCenter defaultCenter] postNotificationName:@"sourceApplication" object:nil userInfo:params];
	}

	return YES;
}

第二步:

// 新浪微博分享
- (IBAction)sharedSinAction:(id)sender
{
	ALIAS( [SinaWeibo sharedInstance], singan );
	
	singan.post = [self tPost];

	singan.whenShareSucceed = ^{
		// 分享成功
		NSLog(@"分享成功");
	};

	singan.whenShareFailed = ^{
		// 分享失败
		NSLog(@"分享失败");
	};

	[singan sharedSin];
}


- (Shared_Post *)tPost
{
	Shared_Post * post = [[Shared_Post alloc] init];
	post.title = @"title";
	post.text  = @"text";
	post.photo = [UIImage imageNamed:@"1.png"];
	post.thum  = [UIImage imageNamed:@"Icon.png"];
	post.url  = @"www.baidu.com";

	return post;
}

About

客户端分享(新浪微博分享,QQ分享,QQ空间分享,微信好友分享,微信朋友圈分享与登录)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published