mirror of
https://github.com/RxReader/weibo_kit.git
synced 2025-05-17 15:25:56 +08:00
升级微博SDK
This commit is contained in:
@ -348,14 +348,14 @@ packages:
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
path:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.flutter-io.cn"
|
||||
|
@ -35,13 +35,16 @@
|
||||
result(nil);
|
||||
} else if ([@"isInstalled" isEqualToString:call.method]) {
|
||||
result([NSNumber numberWithBool:[WeiboSDK isWeiboAppInstalled]]);
|
||||
} else if ([@"isSupportMultipleImage" isEqualToString:call.method]) {
|
||||
result([NSNumber numberWithBool:YES]);
|
||||
} else if ([@"auth" isEqualToString:call.method]) {
|
||||
[self handleAuthCall:call result:result];
|
||||
} else if ([@"shareText" isEqualToString:call.method]) {
|
||||
[self handleShareTextCall:call result:result];
|
||||
} else if ([@"shareImage" isEqualToString:call.method] ||
|
||||
} else if ([@"shareText" isEqualToString:call.method] ||
|
||||
[@"shareImage" isEqualToString:call.method] ||
|
||||
[@"shareMultiImage" isEqualToString:call.method] ||
|
||||
[@"shareVideo" isEqualToString:call.method] ||
|
||||
[@"shareWebpage" isEqualToString:call.method]) {
|
||||
[self handleShareMediaCall:call result:result];
|
||||
[self handleShareCall:call result:result];
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
@ -60,22 +63,11 @@
|
||||
result(nil);
|
||||
}
|
||||
|
||||
- (void)handleShareTextCall:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||
WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest request];
|
||||
- (void)handleShareCall:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||
WBMessageObject *message = [WBMessageObject message];
|
||||
message.text = call.arguments[@"text"];
|
||||
request.message = message;
|
||||
[WeiboSDK sendRequest:request
|
||||
completion:^(BOOL success){
|
||||
// do nothing
|
||||
}];
|
||||
result(nil);
|
||||
}
|
||||
|
||||
- (void)handleShareMediaCall:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||
WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest request];
|
||||
WBMessageObject *message = [WBMessageObject message];
|
||||
if ([@"shareImage" isEqualToString:call.method]) {
|
||||
if ([@"shareText" isEqualToString:call.method]) {
|
||||
message.text = call.arguments[@"text"];
|
||||
} else if ([@"shareImage" isEqualToString:call.method]) {
|
||||
message.text = call.arguments[@"text"];
|
||||
WBImageObject *object = [WBImageObject object];
|
||||
FlutterStandardTypedData *imageData = call.arguments[@"imageData"];
|
||||
@ -87,6 +79,23 @@
|
||||
object.imageData = [NSData dataWithContentsOfFile:imageUrl.path];
|
||||
}
|
||||
message.imageObject = object;
|
||||
} else if ([@"shareMultiImage" isEqualToString:call.method]) {
|
||||
message.text = call.arguments[@"text"];
|
||||
WBImageObject *object = [WBImageObject object];
|
||||
NSArray *imageUris = call.arguments[@"imageUris"];
|
||||
NSMutableArray<UIImage *>* images = [[NSMutableArray alloc] init];
|
||||
for (NSString *imageUri in imageUris) {
|
||||
NSURL *imageUrl = [NSURL URLWithString:imageUri];
|
||||
[images addObject:[UIImage imageWithContentsOfFile:imageUrl.path]];
|
||||
}
|
||||
[object addImages:images];
|
||||
message.imageObject = object;
|
||||
} else if ([@"shareVideo" isEqualToString:call.method]) {
|
||||
message.text = call.arguments[@"text"];
|
||||
WBNewVideoObject *object = [WBNewVideoObject object];
|
||||
NSString *videoUri = call.arguments[@"videoUri"];
|
||||
[object addVideo:[NSURL URLWithString:videoUri]];
|
||||
message.videoObject = object;
|
||||
} else if ([@"shareWebpage" isEqualToString:call.method]) {
|
||||
WBWebpageObject *object = [WBWebpageObject object];
|
||||
object.objectID = [[NSUUID UUID].UUIDString stringByReplacingOccurrencesOfString:@"-" withString:@""];
|
||||
@ -99,6 +108,7 @@
|
||||
object.webpageUrl = call.arguments[@"webpageUrl"];
|
||||
message.mediaObject = object;
|
||||
}
|
||||
WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest request];
|
||||
request.message = message;
|
||||
[WeiboSDK sendRequest:request
|
||||
completion:^(BOOL success){
|
||||
|
@ -118,7 +118,7 @@ class MethodChannelWeiboKit extends WeiboKitPlatform {
|
||||
bool clientOnly = false,
|
||||
}) {
|
||||
assert(text == null || text.length <= 1024);
|
||||
assert(imageUris.isNotEmpty && imageUris.every((Uri element) => element.isScheme('file')));
|
||||
assert(imageUris.isNotEmpty && imageUris.every((Uri element) => element.isScheme('file')) && imageUris.map((Uri element) => File.fromUri(element).lengthSync()).reduce((int value, int element) => value + element) <= 30 * 1024 * 1024);
|
||||
return methodChannel.invokeMethod<void>(
|
||||
'shareMultiImage',
|
||||
<String, dynamic>{
|
||||
@ -136,7 +136,7 @@ class MethodChannelWeiboKit extends WeiboKitPlatform {
|
||||
bool clientOnly = false,
|
||||
}) {
|
||||
assert(text == null || text.length <= 1024);
|
||||
assert(videoUri.isScheme('file'));
|
||||
assert(videoUri.isScheme('file') && File.fromUri(videoUri).lengthSync() <= 50 * 1024 * 1024);
|
||||
return methodChannel.invokeMethod<void>(
|
||||
'shareVideo',
|
||||
<String, dynamic>{
|
||||
|
@ -63,18 +63,18 @@ abstract class WeiboKitPlatform extends PlatformInterface {
|
||||
/// 分享 - 文本
|
||||
Future<void> shareText({
|
||||
required String text,
|
||||
bool clientOnly = false,
|
||||
bool clientOnly = false/* Android Only */,
|
||||
}) {
|
||||
throw UnimplementedError('shareText({required text, clientOnly}) has not been implemented.');
|
||||
}
|
||||
|
||||
/// 分享 - 图片
|
||||
/// 图片文件分享用 shareMultiImage
|
||||
/// Android 图片文件分享用 shareMultiImage
|
||||
Future<void> shareImage({
|
||||
String? text,
|
||||
Uint8List? imageData,
|
||||
Uri? imageUri,
|
||||
bool clientOnly = false,
|
||||
bool clientOnly = false/* Android Only */,
|
||||
}) {
|
||||
throw UnimplementedError('shareImage({text, imageData, imageUri, clientOnly}) has not been implemented.');
|
||||
}
|
||||
@ -83,7 +83,7 @@ abstract class WeiboKitPlatform extends PlatformInterface {
|
||||
Future<void> shareMultiImage({
|
||||
String? text,
|
||||
required List<Uri> imageUris,
|
||||
bool clientOnly = false,
|
||||
bool clientOnly = false/* Android Only */,
|
||||
}) {
|
||||
throw UnimplementedError('shareMultiImage({text, required imageUris, clientOnly}) has not been implemented.');
|
||||
}
|
||||
@ -92,19 +92,18 @@ abstract class WeiboKitPlatform extends PlatformInterface {
|
||||
Future<void> shareVideo({
|
||||
String? text,
|
||||
required Uri videoUri,
|
||||
bool clientOnly = false,
|
||||
bool clientOnly = false/* Android Only */,
|
||||
}) {
|
||||
throw UnimplementedError('shareVideo({text, required videoUri, clientOnly}) has not been implemented.');
|
||||
}
|
||||
|
||||
/// 分享 - 网页
|
||||
/// iOS:分享多媒体已经弃用 请不要用相关api
|
||||
Future<void> shareWebpage({
|
||||
required String title,
|
||||
required String description,
|
||||
required Uint8List thumbData,
|
||||
required String webpageUrl,
|
||||
bool clientOnly = false,
|
||||
bool clientOnly = false/* Android Only */,
|
||||
}) {
|
||||
throw UnimplementedError('shareWebpage({required title, required description, required thumbData, required webpageUrl, clientOnly}) has not been implemented.');
|
||||
}
|
||||
|
Reference in New Issue
Block a user