标签:
/** * 生成完整的 scheme url */ - (NSString*)_genShareUrl:(XZHMessage *)msg to:(XZHTencentPlatform)shareTo { NSString *url = [[NSString alloc] initWithString:ShareSchema]; NSString *boundleName = [XZHShareManager base64Encode:[XZHShareManager CFBundleDisplayName]]; NSString *callback_name = [[self optionDict] objectForKey:@"callback_name"]; NSMutableDictionary *params = [@{ @"thirdAppDisplayName" : boundleName, @"version" : @"1", @"cflag" : [NSString stringWithFormat:@"%ld", shareTo], @"callback_type" : @"scheme", @"generalpastboard" : @"1", @"callback_name" : callback_name, @"src_type" : @"app", @"shareType" : @"0", } mutableCopy]; //如果未给当前message对象设置 分享消息类型,则默认为 news类型 if (msg.link && !msg.messageType) { msg.messageType = XZHMessageNews; } NSDictionary *subParams = nil; if ([msg computeMessageType] == XZHMessageText) { NSString *fileData = [XZHShareManager base64AndUrlEncode:msg.title]; subParams = @{ @"file_type" : @"text", @"file_data" : fileData }; } else if ([msg computeMessageType] == XZHMessageImage) { //将message保存到剪贴板 NSDictionary *data=@{ @"file_data":msg.imageData, @"previewimagedata":msg.thumbImageData?:msg.imageData }; [[XZHShareManager manager] clipBoardSave:data ForKey:SaveObjectForQQPlatformKey Encoding:XZHClipBoardNSKeyedArchiver]; NSString *title = [XZHShareManager base64AndUrlEncode:msg.title]; NSString *desc = [XZHShareManager base64AndUrlEncode:msg.desc]; subParams = @{ @"file_type" : @"img", @"title" : title, @"objectlocation" : @"pasteboard", @"description" : desc, }; }else if ([msg computeMessageType] == XZHMessageNews) { NSDictionary *data=@{@"previewimagedata":msg.imageData}; //图片保存到剪贴板 [[XZHShareManager manager] clipBoardSave:data ForKey:SaveObjectForQQPlatformKey Encoding:XZHClipBoardNSKeyedArchiver]; NSString *title = [XZHShareManager base64AndUrlEncode:msg.title]; NSString *url = [XZHShareManager base64AndUrlEncode:msg.link]; NSString *desc = [XZHShareManager base64AndUrlEncode:msg.desc]; NSString *msgType=@"news"; if (msg.messageType == XZHMessageNews) { msgType = @"news"; } else if (msg.messageType == XZHMessageAudio) { msgType = @"audio"; } subParams = @{ @"file_type" : msgType, @"title" : title, @"url" : url, @"description" : desc, @"objectlocation" : @"pasteboard", }; } //得到最后字典 [params addEntriesFromDictionary:subParams]; //构造最后的scheme url url = [XZHShareManager urlStringWithOriginUrlString:url appendParameters:params]; return url; }
+ (void)openURL:(NSString *)url { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; }
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { //其他应用掉起当前应用时,传回的参数,如果传入的url能够处理 if ([[XZHShareManager manager] handleOpenURL:url]) { return YES; } //不能处理的App调起 return YES; }
标签:
原文地址:http://www.cnblogs.com/xiongzenghui/p/4626252.html