提交 d603a5fb authored 作者: JarvanMo's avatar JarvanMo

ios share

上级 451f258e
...@@ -135,12 +135,12 @@ object FluwxShareHandler { ...@@ -135,12 +135,12 @@ object FluwxShareHandler {
miniProgramObj.miniprogramType = call.argument("miniProgramType")// 正式版:0,测试版:1,体验版:2 miniProgramObj.miniprogramType = call.argument("miniProgramType")// 正式版:0,测试版:1,体验版:2
miniProgramObj.userName = call.argument("userName") // 小程序原始id miniProgramObj.userName = call.argument("userName") // 小程序原始id
miniProgramObj.path = call.argument("path") //小程序页面路径 miniProgramObj.path = call.argument("path") //小程序页面路径
miniProgramObj.withShareTicket = call.argument("withShareTicket")
val msg = WXMediaMessage(miniProgramObj) val msg = WXMediaMessage(miniProgramObj)
msg.title = call.argument("title") // 小程序消息title msg.title = call.argument(WechatPluginKeys.TITLE) // 小程序消息title
msg.description = call.argument("description") // 小程序消息desc msg.description = call.argument("description") // 小程序消息desc
val thumbnail: String? = call.argument(WechatPluginKeys.THUMBNAIL) val thumbnail: String? = call.argument(WechatPluginKeys.THUMBNAIL)
launch { launch {
if (thumbnail.isNullOrBlank()) { if (thumbnail.isNullOrBlank()) {
msg.thumbData = null msg.thumbData = null
...@@ -234,7 +234,7 @@ object FluwxShareHandler { ...@@ -234,7 +234,7 @@ object FluwxShareHandler {
val music = WXMusicObject() val music = WXMusicObject()
val musicUrl: String? = call.argument("musicUrl") val musicUrl: String? = call.argument("musicUrl")
val musicLowBandUrl: String? = call.argument("musicLowBandUrl") val musicLowBandUrl: String? = call.argument("musicLowBandUrl")
if (musicUrl != null) { if (musicUrl != null && musicUrl.isNotBlank()) {
music.musicUrl = musicUrl music.musicUrl = musicUrl
music.musicDataUrl = call.argument("musicDataUrl") music.musicDataUrl = call.argument("musicDataUrl")
} else { } else {
...@@ -265,7 +265,7 @@ object FluwxShareHandler { ...@@ -265,7 +265,7 @@ object FluwxShareHandler {
val video = WXVideoObject() val video = WXVideoObject()
val videoUrl: String? = call.argument("videoUrl") val videoUrl: String? = call.argument("videoUrl")
val videoLowBandUrl: String? = call.argument("videoLowBandUrl") val videoLowBandUrl: String? = call.argument("videoLowBandUrl")
if (videoUrl != null) { if (videoUrl != null && videoUrl.isNotBlank()) {
video.videoUrl = videoUrl video.videoUrl = videoUrl
} else { } else {
video.videoLowBandUrl = videoLowBandUrl video.videoLowBandUrl = videoLowBandUrl
......
...@@ -11,4 +11,20 @@ ...@@ -11,4 +11,20 @@
return [super application:application didFinishLaunchingWithOptions:launchOptions]; return [super application:application didFinishLaunchingWithOptions:launchOptions];
} }
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
}
@end @end
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>${PROJECT_NAME}</string> <string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
...@@ -35,8 +35,17 @@ ...@@ -35,8 +35,17 @@
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
</array>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
...@@ -56,16 +65,5 @@ ...@@ -56,16 +65,5 @@
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key> <key>UIViewControllerBasedStatusBarAppearance</key>
<false/> <false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict> </dict>
</plist> </plist>
...@@ -69,7 +69,7 @@ BOOL isWeChatRegistered = NO; ...@@ -69,7 +69,7 @@ BOOL isWeChatRegistered = NO;
return; return;
} }
NSString *appId = call.arguments[appId]; NSString *appId = call.arguments[@"appId"];
if ([StringUtil isBlank:appId]) { if ([StringUtil isBlank:appId]) {
result([FlutterError errorWithCode:@"invalid app id" message:@"are you sure your app id is correct ? " details:appId]); result([FlutterError errorWithCode:@"invalid app id" message:@"are you sure your app id is correct ? " details:appId]);
return; return;
......
...@@ -43,6 +43,12 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -43,6 +43,12 @@ NSObject <FlutterPluginRegistrar> *_registrar;
[self shareImage:call result:result]; [self shareImage:call result:result];
} else if ([shareWebPage isEqualToString:call.method]) { } else if ([shareWebPage isEqualToString:call.method]) {
[self shareWebPage:call result:result]; [self shareWebPage:call result:result];
} else if ([shareMusic isEqualToString:call.method]) {
[self shareMusic:call result:result];
} else if ([shareVideo isEqualToString:call.method]) {
[self shareVideo:call result:result];
} else if([shareMiniProgram isEqualToString:call.method]){
[self shareMiniProgram:call result:result];
} }
...@@ -52,7 +58,7 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -52,7 +58,7 @@ NSObject <FlutterPluginRegistrar> *_registrar;
NSString *text = call.arguments[fluwxKeyText]; NSString *text = call.arguments[fluwxKeyText];
NSString *scene = call.arguments[fluwxKeyScene]; NSString *scene = call.arguments[fluwxKeyScene];
BOOL done = [WXApiRequestHandler sendText:text InScene:[StringToWeChatScene toScene:scene]]; BOOL done = [WXApiRequestHandler sendText:text InScene:[StringToWeChatScene toScene:scene]];
result(@{fluwxKeyPlatform:fluwxKeyIOS,fluwxKeyResult:@(done)}); result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
} }
...@@ -91,7 +97,6 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -91,7 +97,6 @@ NSObject <FlutterPluginRegistrar> *_registrar;
UIImage *thumbnailImage = [self getThumbnail:thumbnail size:32 * 1024]; UIImage *thumbnailImage = [self getThumbnail:thumbnail size:32 * 1024];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
NSString *scene = call.arguments[fluwxKeyScene]; NSString *scene = call.arguments[fluwxKeyScene];
...@@ -101,7 +106,7 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -101,7 +106,7 @@ NSObject <FlutterPluginRegistrar> *_registrar;
Action:fluwxKeyMessageAction Action:fluwxKeyMessageAction
ThumbImage:thumbnailImage ThumbImage:thumbnailImage
InScene:[StringToWeChatScene toScene:scene]]; InScene:[StringToWeChatScene toScene:scene]];
result(@{fluwxKeyPlatform:fluwxKeyIOS,fluwxKeyResult:@(done)}); result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
}); });
...@@ -110,7 +115,6 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -110,7 +115,6 @@ NSObject <FlutterPluginRegistrar> *_registrar;
} }
- (void)shareAssetImage:(FlutterMethodCall *)call result:(FlutterResult)result imagePath:(NSString *)imagePath { - (void)shareAssetImage:(FlutterMethodCall *)call result:(FlutterResult)result imagePath:(NSString *)imagePath {
...@@ -137,7 +141,7 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -137,7 +141,7 @@ NSObject <FlutterPluginRegistrar> *_registrar;
Action:fluwxKeyMessageAction Action:fluwxKeyMessageAction
ThumbImage:thumbnailImage ThumbImage:thumbnailImage
InScene:[StringToWeChatScene toScene:scene]]; InScene:[StringToWeChatScene toScene:scene]];
result(@{fluwxKeyPlatform:fluwxKeyIOS,fluwxKeyResult:@(done)}); result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
}); });
...@@ -146,7 +150,6 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -146,7 +150,6 @@ NSObject <FlutterPluginRegistrar> *_registrar;
} }
- (void)shareWebPage:(FlutterMethodCall *)call result:(FlutterResult)result { - (void)shareWebPage:(FlutterMethodCall *)call result:(FlutterResult)result {
dispatch_queue_t globalQueue = dispatch_get_global_queue(1, 1); dispatch_queue_t globalQueue = dispatch_get_global_queue(1, 1);
...@@ -154,45 +157,143 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -154,45 +157,143 @@ NSObject <FlutterPluginRegistrar> *_registrar;
NSString *thumbnail = call.arguments[fluwxKeyThumbnail]; NSString *thumbnail = call.arguments[fluwxKeyThumbnail];
UIImage *thumbnailImage =[self getThumbnail:thumbnail size:32 * 1024]; UIImage *thumbnailImage = [self getThumbnail:thumbnail size:32 * 1024];
NSData *imageData = [NSData dataWithContentsOfFile:[self readImageFromAssets:@""]];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
NSString *webPageUrl = call.arguments[@"webPage"]; NSString *webPageUrl = call.arguments[@"webPage"];
NSString *scene = call.arguments[fluwxKeyScene]; NSString *scene = call.arguments[fluwxKeyScene];
BOOL done = [WXApiRequestHandler sendImageData:imageData
BOOL done = [WXApiRequestHandler sendLinkURL:webPageUrl
TagName:call.arguments[fluwxKeyMediaTagName] TagName:call.arguments[fluwxKeyMediaTagName]
MessageExt:fluwxKeyMessageExt Title:call.arguments[fluwxKeyTitle]
Action:fluwxKeyMessageAction Description:call.arguments[fluwxKeyDescription]
ThumbImage:thumbnailImage ThumbImage:thumbnailImage
MessageExt:call.arguments[fluwxKeyMessageExt]
MessageAction:call.arguments[fluwxKeyMessageAction]
InScene:[StringToWeChatScene toScene:scene]]; InScene:[StringToWeChatScene toScene:scene]];
result(@{fluwxKeyPlatform:fluwxKeyIOS,fluwxKeyResult:@(done)}); result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
}); });
}); });
}
- (void)shareMusic:(FlutterMethodCall *)call result:(FlutterResult)result {
dispatch_queue_t globalQueue = dispatch_get_global_queue(1, 1);
dispatch_async(globalQueue, ^{
NSString *thumbnail = call.arguments[fluwxKeyThumbnail];
UIImage *thumbnailImage = [self getThumbnail:thumbnail size:32 * 1024];
NSString *imagePath = call.arguments[fluwxKeyImage];
dispatch_async(dispatch_get_main_queue(), ^{
NSString *text = call.arguments[fluwxKeyText];
NSString *scene = call.arguments[fluwxKeyScene]; NSString *scene = call.arguments[fluwxKeyScene];
BOOL done = [WXApiRequestHandler sendText:text InScene:[StringToWeChatScene toScene:scene]];
result(@(done)); BOOL done = [WXApiRequestHandler sendMusicURL:call.arguments[@"musicUrl"]
dataURL:call.arguments[@"musicDataUrl"]
MusicLowBandUrl:call.arguments[@"musicLowBandUrl"]
MusicLowBandDataUrl:call.arguments[@"musicLowBandDataUrl"]
Title:call.arguments[fluwxKeyTitle]
Description:call.arguments[fluwxKeyDescription]
ThumbImage:thumbnailImage
MessageExt:call.arguments[fluwxKeyMessageExt]
MessageAction:call.arguments[fluwxKeyMessageAction]
TagName:call.arguments[fluwxKeyMediaTagName]
InScene:[StringToWeChatScene toScene:scene]];
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
});
});
} }
- (void)shareVideo:(FlutterMethodCall *)call result:(FlutterResult)result {
dispatch_queue_t globalQueue = dispatch_get_global_queue(1, 1);
dispatch_async(globalQueue, ^{
NSString *thumbnail = call.arguments[fluwxKeyThumbnail];
UIImage *thumbnailImage = [self getThumbnail:thumbnail size:32 * 1024];
- (UIImage *) getThumbnail:(NSString *) thumbnail size:(NSUInteger) size{ dispatch_async(dispatch_get_main_queue(), ^{
NSString *scene = call.arguments[fluwxKeyScene];
BOOL done = [WXApiRequestHandler sendVideoURL:call.arguments[@"videoUrl"]
VideoLowBandUrl:call.arguments[@"videoLowBandUrl"]
Title:call.arguments[fluwxKeyTitle]
Description:call.arguments[fluwxKeyDescription]
ThumbImage:thumbnailImage
MessageExt:call.arguments[fluwxKeyMessageExt]
MessageAction:call.arguments[fluwxKeyMessageAction]
TagName:call.arguments[fluwxKeyMediaTagName]
InScene:[StringToWeChatScene toScene:scene]];
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
});
});
}
- (void)shareMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result {
dispatch_queue_t globalQueue = dispatch_get_global_queue(1, 1);
dispatch_async(globalQueue, ^{
NSString *thumbnail = call.arguments[fluwxKeyThumbnail];
UIImage *thumbnailImage = [self getThumbnail:thumbnail size:120 * 1024];
NSData *hdImageData = nil;
NSString *hdImagePath = call.arguments[@"hdImagePath"];
if (![StringUtil isBlank:hdImagePath]) {
if ([hdImagePath hasPrefix:SCHEMA_ASSETS]) {
hdImageData = [NSData dataWithContentsOfFile:[self readImageFromAssets:hdImagePath]];
} else if ([hdImagePath hasPrefix:SCHEMA_FILE]) {
} else {
NSURL *hdImageURL = [NSURL URLWithString:hdImagePath];
hdImageData = [NSData dataWithContentsOfURL:hdImageURL];
}
}
dispatch_async(dispatch_get_main_queue(), ^{
NSString *scene = call.arguments[fluwxKeyScene];
BOOL done = [WXApiRequestHandler sendMiniProgramWebpageUrl:call.arguments[@"webPageUrl"]
userName:call.arguments[@"userName"]
path:call.arguments[@"path"]
title:fluwxKeyTitle
Description:fluwxKeyDescription
ThumbImage:thumbnailImage
hdImageData:hdImageData
withShareTicket:[call.arguments[@"withShareTicket"] boolValue]
miniProgramType:(WXMiniProgramType) call.arguments[@"miniProgramType"]
MessageExt:call.arguments[fluwxKeyMessageExt]
MessageAction:call.arguments[fluwxKeyMessageAction]
TagName:call.arguments[fluwxKeyMediaTagName]
InScene:[StringToWeChatScene toScene:scene]];
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
});
});
}
- (UIImage *)getThumbnail:(NSString *)thumbnail size:(NSUInteger)size {
UIImage *thumbnailImage = nil; UIImage *thumbnailImage = nil;
...@@ -223,12 +324,12 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -223,12 +324,12 @@ NSObject <FlutterPluginRegistrar> *_registrar;
} }
- (NSString *) readImageFromAssets:(NSString *) imagePath{ - (NSString *)readImageFromAssets:(NSString *)imagePath {
NSArray *array = [self formatAssets:imagePath]; NSArray *array = [self formatAssets:imagePath];
NSString* key ; NSString *key;
if(array[1] == nil){ if (array[1] == nil) {
key = [_registrar lookupKeyForAsset:array[0]]; key = [_registrar lookupKeyForAsset:array[0]];
} else{ } else {
key = [_registrar lookupKeyForAsset:array[0] fromPackage:array[1]]; key = [_registrar lookupKeyForAsset:array[0] fromPackage:array[1]];
} }
...@@ -237,8 +338,7 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -237,8 +338,7 @@ NSObject <FlutterPluginRegistrar> *_registrar;
} }
- (NSArray *)formatAssets:(NSString *)originPath {
-(NSArray *) formatAssets:(NSString *) originPath{
NSString *path = nil; NSString *path = nil;
NSString *packageName = nil; NSString *packageName = nil;
int from = [SCHEMA_ASSETS length]; int from = [SCHEMA_ASSETS length];
...@@ -246,11 +346,11 @@ NSObject <FlutterPluginRegistrar> *_registrar; ...@@ -246,11 +346,11 @@ NSObject <FlutterPluginRegistrar> *_registrar;
NSString *pathWithoutSchema = [originPath substringFromIndex:from toIndex:to]; NSString *pathWithoutSchema = [originPath substringFromIndex:from toIndex:to];
int indexOfPackage = [pathWithoutSchema lastIndexOfString:fluwxKeyPackage]; int indexOfPackage = [pathWithoutSchema lastIndexOfString:fluwxKeyPackage];
if( indexOfPackage != JavaNotFound){ if (indexOfPackage != JavaNotFound) {
path = [pathWithoutSchema substringFromIndex:0 toIndex:indexOfPackage]; path = [pathWithoutSchema substringFromIndex:0 toIndex:indexOfPackage];
int begin = indexOfPackage + [fluwxKeyPackage length]; int begin = indexOfPackage + [fluwxKeyPackage length];
packageName = [pathWithoutSchema substringFromIndex:begin toIndex:[pathWithoutSchema length]]; packageName = [pathWithoutSchema substringFromIndex:begin toIndex:[pathWithoutSchema length]];
} else{ } else {
path = pathWithoutSchema; path = pathWithoutSchema;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "WXApiObject.h" #import "WXApiObject.h"
#import "StringUtil.h"
@interface WXApiRequestHandler : NSObject @interface WXApiRequestHandler : NSObject
...@@ -26,19 +27,30 @@ ...@@ -26,19 +27,30 @@
Title:(NSString *)title Title:(NSString *)title
Description:(NSString *)description Description:(NSString *)description
ThumbImage:(UIImage *)thumbImage ThumbImage:(UIImage *)thumbImage
MessageExt:(NSString *)messageExt
MessageAction:(NSString *)messageAction
InScene:(enum WXScene)scene; InScene:(enum WXScene)scene;
+ (BOOL)sendMusicURL:(NSString *)musicURL + (BOOL)sendMusicURL:(NSString *)musicURL
dataURL:(NSString *)dataURL dataURL:(NSString *)dataURL
MusicLowBandUrl:(NSString *)musicLowBandUrl
MusicLowBandDataUrl:(NSString *)musicLowBandDataUrl
Title:(NSString *)title Title:(NSString *)title
Description:(NSString *)description Description:(NSString *)description
ThumbImage:(UIImage *)thumbImage ThumbImage:(UIImage *)thumbImage
MessageExt:(NSString *)messageExt
MessageAction:(NSString *)messageAction
TagName:(NSString *)tagName
InScene:(enum WXScene)scene; InScene:(enum WXScene)scene;
+ (BOOL)sendVideoURL:(NSString *)videoURL + (BOOL)sendVideoURL:(NSString *)videoURL
VideoLowBandUrl:(NSString *)videoLowBandUrl
Title:(NSString *)title Title:(NSString *)title
Description:(NSString *)description Description:(NSString *)description
ThumbImage:(UIImage *)thumbImage ThumbImage:(UIImage *)thumbImage
MessageExt:(NSString *)messageExt
MessageAction:(NSString *)messageAction
TagName:(NSString *)tagName
InScene:(enum WXScene)scene; InScene:(enum WXScene)scene;
+ (BOOL)sendEmotionData:(NSData *)emotionData + (BOOL)sendEmotionData:(NSData *)emotionData
...@@ -61,6 +73,9 @@ ...@@ -61,6 +73,9 @@
hdImageData:(NSData *)hdImageData hdImageData:(NSData *)hdImageData
withShareTicket:(BOOL)withShareTicket withShareTicket:(BOOL)withShareTicket
miniProgramType:(WXMiniProgramType)programType miniProgramType:(WXMiniProgramType)programType
MessageExt:(NSString *)messageExt
MessageAction:(NSString *)messageAction
TagName:(NSString *)tagName
InScene:(enum WXScene)scene; InScene:(enum WXScene)scene;
+ (BOOL)launchMiniProgramWithUserName:(NSString *)userName + (BOOL)launchMiniProgramWithUserName:(NSString *)userName
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
@implementation WXApiRequestHandler @implementation WXApiRequestHandler
#pragma mark - Public Methods #pragma mark - Public Methods
+ (BOOL)sendText:(NSString *)text + (BOOL)sendText:(NSString *)text
InScene:(enum WXScene)scene { InScene:(enum WXScene)scene {
SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:text SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:text
...@@ -30,9 +31,8 @@ ...@@ -30,9 +31,8 @@
Action:(NSString *)action Action:(NSString *)action
ThumbImage:(UIImage *)thumbImage ThumbImage:(UIImage *)thumbImage
InScene:(enum WXScene)scene InScene:(enum WXScene)scene
title:(NSString *) title title:(NSString *)title
description:(NSString *) description description:(NSString *)description {
{
WXImageObject *ext = [WXImageObject object]; WXImageObject *ext = [WXImageObject object];
ext.imageData = imageData; ext.imageData = imageData;
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
ThumbImage:thumbImage ThumbImage:thumbImage
MediaTag:tagName]; MediaTag:tagName];
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:nil
OrMediaMessage:message OrMediaMessage:message
bText:NO bText:NO
InScene:scene]; InScene:scene];
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
Title:(NSString *)title Title:(NSString *)title
Description:(NSString *)description Description:(NSString *)description
ThumbImage:(UIImage *)thumbImage ThumbImage:(UIImage *)thumbImage
MessageExt:(NSString *)messageExt
MessageAction:(NSString *)messageAction
InScene:(enum WXScene)scene { InScene:(enum WXScene)scene {
WXWebpageObject *ext = [WXWebpageObject object]; WXWebpageObject *ext = [WXWebpageObject object];
ext.webpageUrl = urlString; ext.webpageUrl = urlString;
...@@ -64,12 +66,12 @@ ...@@ -64,12 +66,12 @@
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
Description:description Description:description
Object:ext Object:ext
MessageExt:nil MessageExt:messageExt
MessageAction:nil MessageAction:messageAction
ThumbImage:thumbImage ThumbImage:thumbImage
MediaTag:tagName]; MediaTag:tagName];
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:nil
OrMediaMessage:message OrMediaMessage:message
bText:NO bText:NO
InScene:scene]; InScene:scene];
...@@ -78,23 +80,35 @@ ...@@ -78,23 +80,35 @@
+ (BOOL)sendMusicURL:(NSString *)musicURL + (BOOL)sendMusicURL:(NSString *)musicURL
dataURL:(NSString *)dataURL dataURL:(NSString *)dataURL
MusicLowBandUrl:(NSString *)musicLowBandUrl
MusicLowBandDataUrl:(NSString *)musicLowBandDataUrl
Title:(NSString *)title Title:(NSString *)title
Description:(NSString *)description Description:(NSString *)description
ThumbImage:(UIImage *)thumbImage ThumbImage:(UIImage *)thumbImage
MessageExt:(NSString *)messageExt
MessageAction:(NSString *)messageAction
TagName:(NSString *)tagName
InScene:(enum WXScene)scene { InScene:(enum WXScene)scene {
WXMusicObject *ext = [WXMusicObject object]; WXMusicObject *ext = [WXMusicObject object];
if ([StringUtil isBlank:musicURL]) {
ext.musicLowBandUrl = musicLowBandUrl;
ext.musicLowBandDataUrl = musicLowBandDataUrl;
} else {
ext.musicUrl = musicURL; ext.musicUrl = musicURL;
ext.musicDataUrl = dataURL; ext.musicDataUrl = dataURL;
}
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
Description:description Description:description
Object:ext Object:ext
MessageExt:nil MessageExt:messageExt
MessageAction:nil MessageAction:messageAction
ThumbImage:thumbImage ThumbImage:thumbImage
MediaTag:nil]; MediaTag:tagName];
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:nil
OrMediaMessage:message OrMediaMessage:message
bText:NO bText:NO
InScene:scene]; InScene:scene];
...@@ -103,21 +117,31 @@ ...@@ -103,21 +117,31 @@
} }
+ (BOOL)sendVideoURL:(NSString *)videoURL + (BOOL)sendVideoURL:(NSString *)videoURL
VideoLowBandUrl:(NSString *)videoLowBandUrl
Title:(NSString *)title Title:(NSString *)title
Description:(NSString *)description Description:(NSString *)description
ThumbImage:(UIImage *)thumbImage ThumbImage:(UIImage *)thumbImage
MessageExt:(NSString *)messageExt
MessageAction:(NSString *)messageAction
TagName:(NSString *)tagName
InScene:(enum WXScene)scene { InScene:(enum WXScene)scene {
WXMediaMessage *message = [WXMediaMessage message]; WXMediaMessage *message = [WXMediaMessage message];
message.title = title; message.title = title;
message.description = description; message.description = description;
message.messageExt = messageExt;
message.messageAction = messageAction;
message.mediaTagName = tagName;
[message setThumbImage:thumbImage]; [message setThumbImage:thumbImage];
WXVideoObject *ext = [WXVideoObject object]; WXVideoObject *ext = [WXVideoObject object];
if ([StringUtil isBlank:videoURL]) {
ext.videoLowBandUrl = videoLowBandUrl;
} else {
ext.videoUrl = videoURL; ext.videoUrl = videoURL;
}
message.mediaObject = ext; message.mediaObject = ext;
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:nil
OrMediaMessage:message OrMediaMessage:message
bText:NO bText:NO
InScene:scene]; InScene:scene];
...@@ -135,7 +159,7 @@ ...@@ -135,7 +159,7 @@
message.mediaObject = ext; message.mediaObject = ext;
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:nil
OrMediaMessage:message OrMediaMessage:message
bText:NO bText:NO
InScene:scene]; InScene:scene];
...@@ -159,7 +183,7 @@ ...@@ -159,7 +183,7 @@
message.mediaObject = ext; message.mediaObject = ext;
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:nil
OrMediaMessage:message OrMediaMessage:message
bText:NO bText:NO
InScene:scene]; InScene:scene];
...@@ -175,8 +199,10 @@ ...@@ -175,8 +199,10 @@
hdImageData:(NSData *)hdImageData hdImageData:(NSData *)hdImageData
withShareTicket:(BOOL)withShareTicket withShareTicket:(BOOL)withShareTicket
miniProgramType:(WXMiniProgramType)programType miniProgramType:(WXMiniProgramType)programType
InScene:(enum WXScene)scene MessageExt:(NSString *)messageExt
{ MessageAction:(NSString *)messageAction
TagName:(NSString *)tagName
InScene:(enum WXScene)scene {
WXMiniProgramObject *ext = [WXMiniProgramObject object]; WXMiniProgramObject *ext = [WXMiniProgramObject object];
ext.webpageUrl = webpageUrl; ext.webpageUrl = webpageUrl;
ext.userName = userName; ext.userName = userName;
...@@ -188,12 +214,12 @@ ...@@ -188,12 +214,12 @@
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
Description:description Description:description
Object:ext Object:ext
MessageExt:nil MessageExt:messageExt
MessageAction:nil MessageAction:messageAction
ThumbImage:thumbImage ThumbImage:thumbImage
MediaTag:nil]; MediaTag:tagName];
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:nil
OrMediaMessage:message OrMediaMessage:message
bText:NO bText:NO
InScene:scene]; InScene:scene];
...@@ -203,8 +229,7 @@ ...@@ -203,8 +229,7 @@
+ (BOOL)launchMiniProgramWithUserName:(NSString *)userName + (BOOL)launchMiniProgramWithUserName:(NSString *)userName
path:(NSString *)path path:(NSString *)path
type:(WXMiniProgramType)miniProgramType type:(WXMiniProgramType)miniProgramType {
{
WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object]; WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
launchMiniProgramReq.userName = userName; launchMiniProgramReq.userName = userName;
launchMiniProgramReq.path = path; launchMiniProgramReq.path = path;
...@@ -214,7 +239,6 @@ ...@@ -214,7 +239,6 @@
} }
+ (BOOL)sendAppContentData:(NSData *)data + (BOOL)sendAppContentData:(NSData *)data
ExtInfo:(NSString *)info ExtInfo:(NSString *)info
ExtURL:(NSString *)url ExtURL:(NSString *)url
...@@ -237,7 +261,7 @@ ...@@ -237,7 +261,7 @@
ThumbImage:thumbImage ThumbImage:thumbImage
MediaTag:nil]; MediaTag:nil];
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:nil
OrMediaMessage:message OrMediaMessage:message
bText:NO bText:NO
InScene:scene]; InScene:scene];
...@@ -245,7 +269,7 @@ ...@@ -245,7 +269,7 @@
} }
+ (BOOL)addCardsToCardPackage:(NSArray *)cardIds cardExts:(NSArray *)cardExts{ + (BOOL)addCardsToCardPackage:(NSArray *)cardIds cardExts:(NSArray *)cardExts {
NSMutableArray *cardItems = [NSMutableArray array]; NSMutableArray *cardItems = [NSMutableArray array];
for (NSString *cardId in cardIds) { for (NSString *cardId in cardIds) {
WXCardItem *item = [[WXCardItem alloc] init]; WXCardItem *item = [[WXCardItem alloc] init];
...@@ -269,8 +293,7 @@ ...@@ -269,8 +293,7 @@
cardSign:(NSString *)cardSign cardSign:(NSString *)cardSign
nonceStr:(NSString *)nonceStr nonceStr:(NSString *)nonceStr
signType:(NSString *)signType signType:(NSString *)signType
timestamp:(UInt32)timestamp timestamp:(UInt32)timestamp {
{
WXChooseCardReq *chooseCardReq = [[WXChooseCardReq alloc] init]; WXChooseCardReq *chooseCardReq = [[WXChooseCardReq alloc] init];
chooseCardReq.appID = appid; chooseCardReq.appID = appid;
chooseCardReq.cardSign = cardSign; chooseCardReq.cardSign = cardSign;
...@@ -285,7 +308,7 @@ ...@@ -285,7 +308,7 @@
State:(NSString *)state State:(NSString *)state
OpenID:(NSString *)openID OpenID:(NSString *)openID
InViewController:(UIViewController *)viewController { InViewController:(UIViewController *)viewController {
SendAuthReq* req = [[SendAuthReq alloc] init]; SendAuthReq *req = [[SendAuthReq alloc] init];
req.scope = scope; // @"post_timeline,sns" req.scope = scope; // @"post_timeline,sns"
req.state = state; req.state = state;
req.openID = openID; req.openID = openID;
...@@ -300,7 +323,7 @@ ...@@ -300,7 +323,7 @@
UserName:(NSString *)userName UserName:(NSString *)userName
ExtMsg:(NSString *)extMessage { ExtMsg:(NSString *)extMessage {
[WXApi registerApp:appID]; [WXApi registerApp:appID];
JumpToBizProfileReq *req = [[JumpToBizProfileReq alloc]init]; JumpToBizProfileReq *req = [[JumpToBizProfileReq alloc] init];
req.profileType = WXBizProfileType_Device; req.profileType = WXBizProfileType_Device;
req.username = userName; req.username = userName;
req.extMsg = extMessage; req.extMsg = extMessage;
...@@ -312,15 +335,14 @@ ...@@ -312,15 +335,14 @@
tousrname:(NSString *)tousrname tousrname:(NSString *)tousrname
ExtMsg:(NSString *)extMsg { ExtMsg:(NSString *)extMsg {
[WXApi registerApp:appID]; [WXApi registerApp:appID];
JumpToBizWebviewReq *req = [[JumpToBizWebviewReq alloc]init]; JumpToBizWebviewReq *req = [[JumpToBizWebviewReq alloc] init];
req.tousrname = tousrname; req.tousrname = tousrname;
req.extMsg = extMsg; req.extMsg = extMsg;
req.webType = WXMPWebviewType_Ad; req.webType = WXMPWebviewType_Ad;
return [WXApi sendReq:req]; return [WXApi sendReq:req];
} }
+ (BOOL)openUrl:(NSString *)url + (BOOL)openUrl:(NSString *)url {
{
OpenWebviewReq *req = [[OpenWebviewReq alloc] init]; OpenWebviewReq *req = [[OpenWebviewReq alloc] init];
req.url = url; req.url = url;
return [WXApi sendReq:req]; return [WXApi sendReq:req];
...@@ -330,8 +352,7 @@ ...@@ -330,8 +352,7 @@
cardSign:(NSString *)cardSign cardSign:(NSString *)cardSign
nonceStr:(NSString *)nonceStr nonceStr:(NSString *)nonceStr
signType:(NSString *)signType signType:(NSString *)signType
timestamp:(UInt32)timestamp timestamp:(UInt32)timestamp {
{
WXChooseInvoiceReq *chooseInvoiceReq = [[WXChooseInvoiceReq alloc] init]; WXChooseInvoiceReq *chooseInvoiceReq = [[WXChooseInvoiceReq alloc] init];
chooseInvoiceReq.appID = appid; chooseInvoiceReq.appID = appid;
chooseInvoiceReq.cardSign = cardSign; chooseInvoiceReq.cardSign = cardSign;
......
...@@ -76,6 +76,11 @@ class WeChatShareMiniProgramModel extends WeChatShareModel { ...@@ -76,6 +76,11 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
final String thumbnail; final String thumbnail;
final String hdImagePath;
final bool withShareTicket;
///[hdImagePath] only works on iOS.
WeChatShareMiniProgramModel( WeChatShareMiniProgramModel(
{@required this.webPageUrl, {@required this.webPageUrl,
int miniProgramType, int miniProgramType,
...@@ -84,6 +89,8 @@ class WeChatShareMiniProgramModel extends WeChatShareModel { ...@@ -84,6 +89,8 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
this.title, this.title,
this.description, this.description,
this.thumbnail, this.thumbnail,
this.withShareTicket:false,
this.hdImagePath,
String transaction, String transaction,
WeChatScene scene, WeChatScene scene,
String messageExt, String messageExt,
...@@ -112,7 +119,9 @@ class WeChatShareMiniProgramModel extends WeChatShareModel { ...@@ -112,7 +119,9 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
"description": description, "description": description,
_transaction: transaction, _transaction: transaction,
_scene: scene.toString(), _scene: scene.toString(),
_thumbnail: thumbnail _thumbnail: thumbnail,
"withShareTicket":withShareTicket,
"hdImagePath":hdImagePath
}; };
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论