mirror of
https://github.com/RxReader/tencent_kit.git
synced 2025-06-25 22:29:50 +08:00
Objective-C 代码格式化
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
## 1.0.2 - 2019.12.02
|
## 1.0.2 - 2019.12.02
|
||||||
|
|
||||||
* 优化
|
* 优化
|
||||||
|
* Objective-C 代码格式化
|
||||||
|
|
||||||
## 1.0.1 - 2019.11.26
|
## 1.0.1 - 2019.11.26
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ PODS:
|
|||||||
- Flutter (1.0.0)
|
- Flutter (1.0.0)
|
||||||
- path_provider (0.0.1):
|
- path_provider (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- tencent_kit (1.0.0):
|
- tencent_kit (1.0.2):
|
||||||
- Flutter
|
- Flutter
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
@ -21,8 +21,8 @@ EXTERNAL SOURCES:
|
|||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
|
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
|
||||||
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
|
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
|
||||||
tencent_kit: ef18a7780c8d8503b448f7d8f25b48abd2706e11
|
tencent_kit: b057e0ae9d0c9b5d02c893b3e3ac602200cb733d
|
||||||
|
|
||||||
PODFILE CHECKSUM: 7fb83752f59ead6285236625b82473f90b1cb932
|
PODFILE CHECKSUM: 7fb83752f59ead6285236625b82473f90b1cb932
|
||||||
|
|
||||||
COCOAPODS: 1.8.0
|
COCOAPODS: 1.8.4
|
||||||
|
44
ios/.clang-format
Executable file
44
ios/.clang-format
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
# 基础样式
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
|
||||||
|
# 缩进宽度
|
||||||
|
IndentWidth: 4
|
||||||
|
|
||||||
|
# 圆括号的换行方式
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
|
||||||
|
# 是否允许循环单行
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
|
||||||
|
# 支持一行的if
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
|
||||||
|
# switch的case缩进
|
||||||
|
IndentCaseLabels: true
|
||||||
|
|
||||||
|
# 针对OC的block的缩进宽度
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
|
||||||
|
# 针对OC,属性名后加空格
|
||||||
|
ObjCSpaceAfterProperty: true
|
||||||
|
|
||||||
|
# 每行字符的长度
|
||||||
|
ColumnLimit: 0
|
||||||
|
|
||||||
|
# 注释对齐
|
||||||
|
AlignTrailingComments: true
|
||||||
|
|
||||||
|
# 括号后加空格
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
|
||||||
|
# 不在小括号里加空格
|
||||||
|
SpacesInParentheses: false
|
||||||
|
|
||||||
|
# 不在中括号里加空格
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
|
||||||
|
AllowShortFunctionsOnASingleLine: false
|
@ -3,18 +3,18 @@
|
|||||||
#import <TencentOpenAPI/TencentOAuth.h>
|
#import <TencentOpenAPI/TencentOAuth.h>
|
||||||
|
|
||||||
enum TencentScene {
|
enum TencentScene {
|
||||||
SCENE_QQ = 0,
|
SCENE_QQ = 0,
|
||||||
SCENE_QZONE = 1,
|
SCENE_QZONE = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TencentRetCode {
|
enum TencentRetCode {
|
||||||
// 网络请求成功发送至服务器,并且服务器返回数据格式正确
|
// 网络请求成功发送至服务器,并且服务器返回数据格式正确
|
||||||
// 这里包括所请求业务操作失败的情况,例如没有授权等原因导致
|
// 这里包括所请求业务操作失败的情况,例如没有授权等原因导致
|
||||||
RET_SUCCESS = 0,
|
RET_SUCCESS = 0,
|
||||||
// 网络异常,或服务器返回的数据格式不正确导致无法解析
|
// 网络异常,或服务器返回的数据格式不正确导致无法解析
|
||||||
RET_FAILED = 1,
|
RET_FAILED = 1,
|
||||||
RET_COMMON = -1,
|
RET_COMMON = -1,
|
||||||
RET_USERCANCEL = -2,
|
RET_USERCANCEL = -2,
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface TencentKitPlugin () <TencentSessionDelegate, QQApiInterfaceDelegate>
|
@interface TencentKitPlugin () <TencentSessionDelegate, QQApiInterfaceDelegate>
|
||||||
@ -22,18 +22,18 @@ enum TencentRetCode {
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation TencentKitPlugin {
|
@implementation TencentKitPlugin {
|
||||||
FlutterMethodChannel *_channel;
|
FlutterMethodChannel *_channel;
|
||||||
TencentOAuth *_oauth;
|
TencentOAuth *_oauth;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
|
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
|
||||||
FlutterMethodChannel *channel =
|
FlutterMethodChannel *channel =
|
||||||
[FlutterMethodChannel methodChannelWithName:@"v7lin.github.io/tencent_kit"
|
[FlutterMethodChannel methodChannelWithName:@"v7lin.github.io/tencent_kit"
|
||||||
binaryMessenger:[registrar messenger]];
|
binaryMessenger:[registrar messenger]];
|
||||||
TencentKitPlugin *instance =
|
TencentKitPlugin *instance =
|
||||||
[[TencentKitPlugin alloc] initWithChannel:channel];
|
[[TencentKitPlugin alloc] initWithChannel:channel];
|
||||||
[registrar addApplicationDelegate:instance];
|
[registrar addApplicationDelegate:instance];
|
||||||
[registrar addMethodCallDelegate:instance channel:channel];
|
[registrar addMethodCallDelegate:instance channel:channel];
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSString *const METHOD_REGISTERAPP = @"registerApp";
|
static NSString *const METHOD_REGISTERAPP = @"registerApp";
|
||||||
@ -72,264 +72,267 @@ static NSString *const ARGUMENT_KEY_RESULT_CREATE_AT = @"create_at";
|
|||||||
static NSString *const SCHEME_FILE = @"file";
|
static NSString *const SCHEME_FILE = @"file";
|
||||||
|
|
||||||
- (instancetype)initWithChannel:(FlutterMethodChannel *)channel {
|
- (instancetype)initWithChannel:(FlutterMethodChannel *)channel {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
_channel = channel;
|
_channel = channel;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handleMethodCall:(FlutterMethodCall *)call
|
- (void)handleMethodCall:(FlutterMethodCall *)call
|
||||||
result:(FlutterResult)result {
|
result:(FlutterResult)result {
|
||||||
if ([METHOD_REGISTERAPP isEqualToString:call.method]) {
|
if ([METHOD_REGISTERAPP isEqualToString:call.method]) {
|
||||||
NSString *appId = call.arguments[ARGUMENT_KEY_APPID];
|
NSString *appId = call.arguments[ARGUMENT_KEY_APPID];
|
||||||
NSString *universalLink = call.arguments[ARGUMENT_KEY_UNIVERSALLINK];
|
NSString *universalLink = call.arguments[ARGUMENT_KEY_UNIVERSALLINK];
|
||||||
if (universalLink != nil) {
|
if (universalLink != nil) {
|
||||||
_oauth = [[TencentOAuth alloc] initWithAppId:appId
|
_oauth = [[TencentOAuth alloc] initWithAppId:appId
|
||||||
andUniversalLink:universalLink
|
andUniversalLink:universalLink
|
||||||
andDelegate:self];
|
andDelegate:self];
|
||||||
|
} else {
|
||||||
|
_oauth = [[TencentOAuth alloc] initWithAppId:appId andDelegate:self];
|
||||||
|
}
|
||||||
|
result(nil);
|
||||||
|
} else if ([METHOD_ISINSTALLED isEqualToString:call.method]) {
|
||||||
|
result([NSNumber numberWithBool:[TencentOAuth iphoneQQInstalled]]);
|
||||||
|
} else if ([METHOD_LOGIN isEqualToString:call.method]) {
|
||||||
|
[self login:call result:result];
|
||||||
|
} else if ([METHOD_LOGOUT isEqualToString:call.method]) {
|
||||||
|
[self logout:call result:result];
|
||||||
|
} else if ([METHOD_SHAREMOOD isEqualToString:call.method]) {
|
||||||
|
[self shareMood:call result:result];
|
||||||
|
} else if ([METHOD_SHAREIMAGE isEqualToString:call.method]) {
|
||||||
|
[self shareImage:call result:result];
|
||||||
|
} else if ([METHOD_SHAREMUSIC isEqualToString:call.method]) {
|
||||||
|
[self shareMusic:call result:result];
|
||||||
|
} else if ([METHOD_SHAREWEBPAGE isEqualToString:call.method]) {
|
||||||
|
[self shareWebpage:call result:result];
|
||||||
} else {
|
} else {
|
||||||
_oauth = [[TencentOAuth alloc] initWithAppId:appId andDelegate:self];
|
result(FlutterMethodNotImplemented);
|
||||||
}
|
}
|
||||||
result(nil);
|
|
||||||
} else if ([METHOD_ISINSTALLED isEqualToString:call.method]) {
|
|
||||||
result([NSNumber numberWithBool:[TencentOAuth iphoneQQInstalled]]);
|
|
||||||
} else if ([METHOD_LOGIN isEqualToString:call.method]) {
|
|
||||||
[self login:call result:result];
|
|
||||||
} else if ([METHOD_LOGOUT isEqualToString:call.method]) {
|
|
||||||
[self logout:call result:result];
|
|
||||||
} else if ([METHOD_SHAREMOOD isEqualToString:call.method]) {
|
|
||||||
[self shareMood:call result:result];
|
|
||||||
} else if ([METHOD_SHAREIMAGE isEqualToString:call.method]) {
|
|
||||||
[self shareImage:call result:result];
|
|
||||||
} else if ([METHOD_SHAREMUSIC isEqualToString:call.method]) {
|
|
||||||
[self shareMusic:call result:result];
|
|
||||||
} else if ([METHOD_SHAREWEBPAGE isEqualToString:call.method]) {
|
|
||||||
[self shareWebpage:call result:result];
|
|
||||||
} else {
|
|
||||||
result(FlutterMethodNotImplemented);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)login:(FlutterMethodCall *)call result:(FlutterResult)result {
|
- (void)login:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||||
if (_oauth != nil) {
|
if (_oauth != nil) {
|
||||||
NSString *scope = call.arguments[ARGUMENT_KEY_SCOPE];
|
NSString *scope = call.arguments[ARGUMENT_KEY_SCOPE];
|
||||||
NSArray *permissions = [scope componentsSeparatedByString:@","];
|
NSArray *permissions = [scope componentsSeparatedByString:@","];
|
||||||
[_oauth authorize:permissions];
|
[_oauth authorize:permissions];
|
||||||
}
|
}
|
||||||
result(nil);
|
result(nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)logout:(FlutterMethodCall *)call result:(FlutterResult)result {
|
- (void)logout:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||||
if (_oauth != nil) {
|
if (_oauth != nil) {
|
||||||
[_oauth logout:self];
|
[_oauth logout:self];
|
||||||
}
|
}
|
||||||
result(nil);
|
result(nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)shareMood:(FlutterMethodCall *)call result:(FlutterResult)result {
|
- (void)shareMood:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||||
NSNumber *scene = call.arguments[ARGUMENT_KEY_SCENE];
|
NSNumber *scene = call.arguments[ARGUMENT_KEY_SCENE];
|
||||||
if (scene.intValue == SCENE_QZONE) {
|
if (scene.intValue == SCENE_QZONE) {
|
||||||
NSString *summary = call.arguments[ARGUMENT_KEY_SUMMARY];
|
NSString *summary = call.arguments[ARGUMENT_KEY_SUMMARY];
|
||||||
NSArray *imageUris = call.arguments[ARGUMENT_KEY_IMAGEURIS];
|
NSArray *imageUris = call.arguments[ARGUMENT_KEY_IMAGEURIS];
|
||||||
NSString *videoUri = call.arguments[ARGUMENT_KEY_VIDEOURI];
|
NSString *videoUri = call.arguments[ARGUMENT_KEY_VIDEOURI];
|
||||||
|
|
||||||
if (videoUri == nil || videoUri.length == 0) {
|
if (videoUri == nil || videoUri.length == 0) {
|
||||||
NSMutableArray *imageDatas = [NSMutableArray array];
|
NSMutableArray *imageDatas = [NSMutableArray array];
|
||||||
if (imageUris != nil && imageUris.count > 0) {
|
if (imageUris != nil && imageUris.count > 0) {
|
||||||
for (NSString *imageUri in imageUris) {
|
for (NSString *imageUri in imageUris) {
|
||||||
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
||||||
NSData *imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
NSData *imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
||||||
[imageDatas addObject:imageData];
|
[imageDatas addObject:imageData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QQApiImageArrayForQZoneObject *object =
|
||||||
|
[QQApiImageArrayForQZoneObject objectWithimageDataArray:imageDatas
|
||||||
|
title:summary
|
||||||
|
extMap:nil];
|
||||||
|
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
||||||
|
[QQApiInterface sendReq:req];
|
||||||
|
} else {
|
||||||
|
QQApiVideoForQZoneObject *object =
|
||||||
|
[QQApiVideoForQZoneObject objectWithAssetURL:videoUri
|
||||||
|
title:summary
|
||||||
|
extMap:nil];
|
||||||
|
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
||||||
|
[QQApiInterface sendReq:req];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
QQApiImageArrayForQZoneObject *object =
|
|
||||||
[QQApiImageArrayForQZoneObject objectWithimageDataArray:imageDatas
|
|
||||||
title:summary
|
|
||||||
extMap:nil];
|
|
||||||
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
|
||||||
[QQApiInterface sendReq:req];
|
|
||||||
} else {
|
|
||||||
QQApiVideoForQZoneObject *object =
|
|
||||||
[QQApiVideoForQZoneObject objectWithAssetURL:videoUri
|
|
||||||
title:summary
|
|
||||||
extMap:nil];
|
|
||||||
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
|
||||||
[QQApiInterface sendReq:req];
|
|
||||||
}
|
}
|
||||||
}
|
result(nil);
|
||||||
result(nil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)shareImage:(FlutterMethodCall *)call result:(FlutterResult)result {
|
- (void)shareImage:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||||
NSNumber *scene = call.arguments[ARGUMENT_KEY_SCENE];
|
NSNumber *scene = call.arguments[ARGUMENT_KEY_SCENE];
|
||||||
if (scene.intValue == SCENE_QQ) {
|
if (scene.intValue == SCENE_QQ) {
|
||||||
NSString *imageUri = call.arguments[ARGUMENT_KEY_IMAGEURI];
|
NSString *imageUri = call.arguments[ARGUMENT_KEY_IMAGEURI];
|
||||||
// NSString *appName = call.arguments[ARGUMENT_KEY_APPNAME];
|
// NSString *appName = call.arguments[ARGUMENT_KEY_APPNAME];
|
||||||
// NSNumber *extInt = call.arguments[ARGUMENT_KEY_EXTINT];
|
// NSNumber *extInt = call.arguments[ARGUMENT_KEY_EXTINT];
|
||||||
|
|
||||||
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
||||||
NSData *imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
NSData *imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
||||||
QQApiImageObject *object = [QQApiImageObject objectWithData:imageData
|
QQApiImageObject *object = [QQApiImageObject objectWithData:imageData
|
||||||
previewImageData:nil
|
previewImageData:nil
|
||||||
title:nil
|
title:nil
|
||||||
description:nil];
|
description:nil];
|
||||||
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
||||||
[QQApiInterface sendReq:req];
|
[QQApiInterface sendReq:req];
|
||||||
}
|
}
|
||||||
result(nil);
|
result(nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)shareMusic:(FlutterMethodCall *)call result:(FlutterResult)result {
|
- (void)shareMusic:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||||
NSNumber *scene = call.arguments[ARGUMENT_KEY_SCENE];
|
NSNumber *scene = call.arguments[ARGUMENT_KEY_SCENE];
|
||||||
NSString *title = call.arguments[ARGUMENT_KEY_TITLE];
|
NSString *title = call.arguments[ARGUMENT_KEY_TITLE];
|
||||||
NSString *summary = call.arguments[ARGUMENT_KEY_SUMMARY];
|
NSString *summary = call.arguments[ARGUMENT_KEY_SUMMARY];
|
||||||
NSString *imageUri = call.arguments[ARGUMENT_KEY_IMAGEURI];
|
NSString *imageUri = call.arguments[ARGUMENT_KEY_IMAGEURI];
|
||||||
NSString *musicUrl = call.arguments[ARGUMENT_KEY_MUSICURL];
|
NSString *musicUrl = call.arguments[ARGUMENT_KEY_MUSICURL];
|
||||||
NSString *targetUrl = call.arguments[ARGUMENT_KEY_TARGETURL];
|
NSString *targetUrl = call.arguments[ARGUMENT_KEY_TARGETURL];
|
||||||
// NSString *appName = call.arguments[ARGUMENT_KEY_APPNAME];
|
// NSString *appName = call.arguments[ARGUMENT_KEY_APPNAME];
|
||||||
// NSNumber *extInt = call.arguments[ARGUMENT_KEY_EXTINT];
|
// NSNumber *extInt = call.arguments[ARGUMENT_KEY_EXTINT];
|
||||||
if (scene.intValue == SCENE_QQ) {
|
if (scene.intValue == SCENE_QQ) {
|
||||||
QQApiAudioObject *object = nil;
|
QQApiAudioObject *object = nil;
|
||||||
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
||||||
if ([SCHEME_FILE isEqualToString:imageUrl.scheme]) {
|
if ([SCHEME_FILE isEqualToString:imageUrl.scheme]) {
|
||||||
NSData *imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
NSData *imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
||||||
object = [QQApiAudioObject objectWithURL:[NSURL URLWithString:targetUrl]
|
object = [QQApiAudioObject objectWithURL:[NSURL URLWithString:targetUrl]
|
||||||
title:title
|
title:title
|
||||||
description:summary
|
description:summary
|
||||||
previewImageData:imageData];
|
previewImageData:imageData];
|
||||||
} else {
|
} else {
|
||||||
object = [QQApiAudioObject objectWithURL:[NSURL URLWithString:targetUrl]
|
object = [QQApiAudioObject objectWithURL:[NSURL URLWithString:targetUrl]
|
||||||
title:title
|
title:title
|
||||||
description:summary
|
description:summary
|
||||||
previewImageURL:imageUrl];
|
previewImageURL:imageUrl];
|
||||||
|
}
|
||||||
|
object.flashURL = [NSURL URLWithString:musicUrl];
|
||||||
|
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
||||||
|
[QQApiInterface sendReq:req];
|
||||||
}
|
}
|
||||||
object.flashURL = [NSURL URLWithString:musicUrl];
|
result(nil);
|
||||||
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
|
||||||
[QQApiInterface sendReq:req];
|
|
||||||
}
|
|
||||||
result(nil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)shareWebpage:(FlutterMethodCall *)call result:(FlutterResult)result {
|
- (void)shareWebpage:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||||
NSNumber *scene = call.arguments[ARGUMENT_KEY_SCENE];
|
NSNumber *scene = call.arguments[ARGUMENT_KEY_SCENE];
|
||||||
NSString *title = call.arguments[ARGUMENT_KEY_TITLE];
|
NSString *title = call.arguments[ARGUMENT_KEY_TITLE];
|
||||||
NSString *summary = call.arguments[ARGUMENT_KEY_SUMMARY];
|
NSString *summary = call.arguments[ARGUMENT_KEY_SUMMARY];
|
||||||
NSString *imageUri = call.arguments[ARGUMENT_KEY_IMAGEURI];
|
NSString *imageUri = call.arguments[ARGUMENT_KEY_IMAGEURI];
|
||||||
NSString *targetUrl = call.arguments[ARGUMENT_KEY_TARGETURL];
|
NSString *targetUrl = call.arguments[ARGUMENT_KEY_TARGETURL];
|
||||||
// NSString *appName = call.arguments[ARGUMENT_KEY_APPNAME];
|
// NSString *appName = call.arguments[ARGUMENT_KEY_APPNAME];
|
||||||
// NSNumber *extInt = call.arguments[ARGUMENT_KEY_EXTINT];
|
// NSNumber *extInt = call.arguments[ARGUMENT_KEY_EXTINT];
|
||||||
|
|
||||||
QQApiNewsObject *object = nil;
|
QQApiNewsObject *object = nil;
|
||||||
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
||||||
if ([SCHEME_FILE isEqualToString:imageUrl.scheme]) {
|
if ([SCHEME_FILE isEqualToString:imageUrl.scheme]) {
|
||||||
NSData *imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
NSData *imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
||||||
object = [QQApiNewsObject objectWithURL:[NSURL URLWithString:targetUrl]
|
object = [QQApiNewsObject objectWithURL:[NSURL URLWithString:targetUrl]
|
||||||
title:title
|
title:title
|
||||||
description:summary
|
description:summary
|
||||||
previewImageData:imageData];
|
previewImageData:imageData];
|
||||||
} else {
|
} else {
|
||||||
object = [QQApiNewsObject objectWithURL:[NSURL URLWithString:targetUrl]
|
object = [QQApiNewsObject objectWithURL:[NSURL URLWithString:targetUrl]
|
||||||
title:title
|
title:title
|
||||||
description:summary
|
description:summary
|
||||||
previewImageURL:imageUrl];
|
previewImageURL:imageUrl];
|
||||||
}
|
}
|
||||||
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:object];
|
||||||
if (scene.intValue == SCENE_QQ) {
|
if (scene.intValue == SCENE_QQ) {
|
||||||
[QQApiInterface sendReq:req];
|
[QQApiInterface sendReq:req];
|
||||||
} else if (scene.intValue == SCENE_QZONE) {
|
} else if (scene.intValue == SCENE_QZONE) {
|
||||||
[QQApiInterface SendReqToQZone:req];
|
[QQApiInterface SendReqToQZone:req];
|
||||||
}
|
}
|
||||||
result(nil);
|
result(nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AppDelegate
|
#pragma mark - AppDelegate
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
|
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
|
||||||
return
|
return
|
||||||
[QQApiInterface handleOpenURL:url delegate:self] ||
|
[QQApiInterface handleOpenURL:url
|
||||||
([TencentOAuth CanHandleOpenURL:url] && [TencentOAuth HandleOpenURL:url]);
|
delegate:self] ||
|
||||||
|
([TencentOAuth CanHandleOpenURL:url] && [TencentOAuth HandleOpenURL:url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application
|
- (BOOL)application:(UIApplication *)application
|
||||||
openURL:(NSURL *)url
|
openURL:(NSURL *)url
|
||||||
sourceApplication:(NSString *)sourceApplication
|
sourceApplication:(NSString *)sourceApplication
|
||||||
annotation:(id)annotation {
|
annotation:(id)annotation {
|
||||||
return
|
return
|
||||||
[QQApiInterface handleOpenURL:url delegate:self] ||
|
[QQApiInterface handleOpenURL:url
|
||||||
([TencentOAuth CanHandleOpenURL:url] && [TencentOAuth HandleOpenURL:url]);
|
delegate:self] ||
|
||||||
|
([TencentOAuth CanHandleOpenURL:url] && [TencentOAuth HandleOpenURL:url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application
|
- (BOOL)application:(UIApplication *)application
|
||||||
openURL:(NSURL *)url
|
openURL:(NSURL *)url
|
||||||
options:
|
options:
|
||||||
(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
|
(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
|
||||||
return
|
return
|
||||||
[QQApiInterface handleOpenURL:url delegate:self] ||
|
[QQApiInterface handleOpenURL:url
|
||||||
([TencentOAuth CanHandleOpenURL:url] && [TencentOAuth HandleOpenURL:url]);
|
delegate:self] ||
|
||||||
|
([TencentOAuth CanHandleOpenURL:url] && [TencentOAuth HandleOpenURL:url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application
|
- (BOOL)application:(UIApplication *)application
|
||||||
continueUserActivity:(NSUserActivity *)userActivity
|
continueUserActivity:(NSUserActivity *)userActivity
|
||||||
restorationHandler:(void (^)(NSArray *_Nonnull))restorationHandler {
|
restorationHandler:(void (^)(NSArray *_Nonnull))restorationHandler {
|
||||||
if ([userActivity.activityType
|
if ([userActivity.activityType
|
||||||
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
|
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
|
||||||
NSURL *url = userActivity.webpageURL;
|
NSURL *url = userActivity.webpageURL;
|
||||||
if (url != nil) {
|
if (url != nil) {
|
||||||
return [QQApiInterface handleOpenUniversallink:url delegate:self] ||
|
return [QQApiInterface handleOpenUniversallink:url delegate:self] ||
|
||||||
([TencentOAuth CanHandleUniversalLink:url] &&
|
([TencentOAuth CanHandleUniversalLink:url] &&
|
||||||
[TencentOAuth HandleUniversalLink:url]);
|
[TencentOAuth HandleUniversalLink:url]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return NO;
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - TencentSessionDelegate
|
#pragma mark - TencentSessionDelegate
|
||||||
|
|
||||||
- (void)tencentDidLogin {
|
- (void)tencentDidLogin {
|
||||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
if (_oauth.accessToken != nil && _oauth.accessToken.length > 0) {
|
if (_oauth.accessToken != nil && _oauth.accessToken.length > 0) {
|
||||||
NSString *openId = _oauth.openId;
|
NSString *openId = _oauth.openId;
|
||||||
NSString *accessToken = _oauth.accessToken;
|
NSString *accessToken = _oauth.accessToken;
|
||||||
long long expiresIn =
|
long long expiresIn =
|
||||||
ceil(_oauth.expirationDate.timeIntervalSinceNow); // 向上取整
|
ceil(_oauth.expirationDate.timeIntervalSinceNow); // 向上取整
|
||||||
long long createAt = [[NSDate date] timeIntervalSince1970] * 1000.0;
|
long long createAt = [[NSDate date] timeIntervalSince1970] * 1000.0;
|
||||||
[dictionary setValue:[NSNumber numberWithInt:RET_SUCCESS]
|
[dictionary setValue:[NSNumber numberWithInt:RET_SUCCESS]
|
||||||
forKey:ARGUMENT_KEY_RESULT_RET];
|
forKey:ARGUMENT_KEY_RESULT_RET];
|
||||||
[dictionary setValue:openId forKey:ARGUMENT_KEY_RESULT_OPENID];
|
[dictionary setValue:openId forKey:ARGUMENT_KEY_RESULT_OPENID];
|
||||||
[dictionary setValue:accessToken forKey:ARGUMENT_KEY_RESULT_ACCESS_TOKEN];
|
[dictionary setValue:accessToken forKey:ARGUMENT_KEY_RESULT_ACCESS_TOKEN];
|
||||||
[dictionary setValue:[NSNumber numberWithLongLong:expiresIn]
|
[dictionary setValue:[NSNumber numberWithLongLong:expiresIn]
|
||||||
forKey:ARGUMENT_KEY_RESULT_EXPIRES_IN];
|
forKey:ARGUMENT_KEY_RESULT_EXPIRES_IN];
|
||||||
[dictionary setValue:[NSNumber numberWithLongLong:createAt]
|
[dictionary setValue:[NSNumber numberWithLongLong:createAt]
|
||||||
forKey:ARGUMENT_KEY_RESULT_CREATE_AT];
|
forKey:ARGUMENT_KEY_RESULT_CREATE_AT];
|
||||||
} else {
|
} else {
|
||||||
// 登录失败
|
// 登录失败
|
||||||
[dictionary setValue:[NSNumber numberWithInt:RET_COMMON]
|
[dictionary setValue:[NSNumber numberWithInt:RET_COMMON]
|
||||||
forKey:ARGUMENT_KEY_RESULT_RET];
|
forKey:ARGUMENT_KEY_RESULT_RET];
|
||||||
}
|
}
|
||||||
[_channel invokeMethod:METHOD_ONLOGINRESP arguments:dictionary];
|
[_channel invokeMethod:METHOD_ONLOGINRESP arguments:dictionary];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tencentDidNotLogin:(BOOL)cancelled {
|
- (void)tencentDidNotLogin:(BOOL)cancelled {
|
||||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
// 取消登录
|
// 取消登录
|
||||||
[dictionary setValue:[NSNumber numberWithInt:RET_USERCANCEL]
|
[dictionary setValue:[NSNumber numberWithInt:RET_USERCANCEL]
|
||||||
forKey:ARGUMENT_KEY_RESULT_RET];
|
forKey:ARGUMENT_KEY_RESULT_RET];
|
||||||
} else {
|
} else {
|
||||||
// 登录失败
|
// 登录失败
|
||||||
[dictionary setValue:[NSNumber numberWithInt:RET_COMMON]
|
[dictionary setValue:[NSNumber numberWithInt:RET_COMMON]
|
||||||
forKey:ARGUMENT_KEY_RESULT_RET];
|
forKey:ARGUMENT_KEY_RESULT_RET];
|
||||||
}
|
}
|
||||||
[_channel invokeMethod:METHOD_ONLOGINRESP arguments:dictionary];
|
[_channel invokeMethod:METHOD_ONLOGINRESP arguments:dictionary];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tencentDidNotNetWork {
|
- (void)tencentDidNotNetWork {
|
||||||
// 登录失败
|
// 登录失败
|
||||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
[dictionary setValue:[NSNumber numberWithInt:RET_COMMON]
|
[dictionary setValue:[NSNumber numberWithInt:RET_COMMON]
|
||||||
forKey:ARGUMENT_KEY_RESULT_RET];
|
forKey:ARGUMENT_KEY_RESULT_RET];
|
||||||
[_channel invokeMethod:METHOD_ONLOGINRESP arguments:dictionary];
|
[_channel invokeMethod:METHOD_ONLOGINRESP arguments:dictionary];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - QQApiInterfaceDelegate
|
#pragma mark - QQApiInterfaceDelegate
|
||||||
@ -338,30 +341,30 @@ static NSString *const SCHEME_FILE = @"file";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)onResp:(QQBaseResp *)resp {
|
- (void)onResp:(QQBaseResp *)resp {
|
||||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
if ([resp isKindOfClass:[SendMessageToQQResp class]]) {
|
if ([resp isKindOfClass:[SendMessageToQQResp class]]) {
|
||||||
switch (resp.result.intValue) {
|
switch (resp.result.intValue) {
|
||||||
case 0:
|
case 0:
|
||||||
// 分享成功
|
// 分享成功
|
||||||
[dictionary setValue:[NSNumber numberWithInt:RET_SUCCESS]
|
[dictionary setValue:[NSNumber numberWithInt:RET_SUCCESS]
|
||||||
forKey:ARGUMENT_KEY_RESULT_RET];
|
forKey:ARGUMENT_KEY_RESULT_RET];
|
||||||
break;
|
break;
|
||||||
case -4:
|
case -4:
|
||||||
// 用户取消
|
// 用户取消
|
||||||
[dictionary setValue:[NSNumber numberWithInt:RET_USERCANCEL]
|
[dictionary setValue:[NSNumber numberWithInt:RET_USERCANCEL]
|
||||||
forKey:ARGUMENT_KEY_RESULT_RET];
|
forKey:ARGUMENT_KEY_RESULT_RET];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
[dictionary setValue:[NSNumber numberWithInt:RET_COMMON]
|
[dictionary setValue:[NSNumber numberWithInt:RET_COMMON]
|
||||||
forKey:ARGUMENT_KEY_RESULT_RET];
|
forKey:ARGUMENT_KEY_RESULT_RET];
|
||||||
NSString *errorMsg =
|
NSString *errorMsg =
|
||||||
[NSString stringWithFormat:@"result: %@, description: %@.",
|
[NSString stringWithFormat:@"result: %@, description: %@.",
|
||||||
resp.result, resp.errorDescription];
|
resp.result, resp.errorDescription];
|
||||||
[dictionary setValue:errorMsg forKey:ARGUMENT_KEY_RESULT_MSG];
|
[dictionary setValue:errorMsg forKey:ARGUMENT_KEY_RESULT_MSG];
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
[_channel invokeMethod:METHOD_ONSHARERESP arguments:dictionary];
|
||||||
}
|
}
|
||||||
[_channel invokeMethod:METHOD_ONSHARERESP arguments:dictionary];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)isOnlineResponse:(NSDictionary *)response {
|
- (void)isOnlineResponse:(NSDictionary *)response {
|
||||||
|
@ -74,7 +74,7 @@ class Tencent {
|
|||||||
}) {
|
}) {
|
||||||
assert(appId != null && appId.isNotEmpty);
|
assert(appId != null && appId.isNotEmpty);
|
||||||
assert(
|
assert(
|
||||||
!Platform.isIOS || universalLink == null || universalLink.isNotEmpty);
|
!Platform.isIOS || (universalLink != null && universalLink.isNotEmpty));
|
||||||
final Map<String, dynamic> arguments = <String, dynamic>{
|
final Map<String, dynamic> arguments = <String, dynamic>{
|
||||||
_ARGUMENT_KEY_APPID: appId,
|
_ARGUMENT_KEY_APPID: appId,
|
||||||
// _ARGUMENT_KEY_UNIVERSALLINK: universalLink,
|
// _ARGUMENT_KEY_UNIVERSALLINK: universalLink,
|
||||||
|
Reference in New Issue
Block a user