提交 408c89ea authored 作者: JarvanMo's avatar JarvanMo

reformat code

上级 0ca4864c
......@@ -105,8 +105,8 @@ class FluwxPlugin(private val registrar: Registrar, channel: MethodChannel) : Me
return
}
if ("openWXApp" == call.method){
val isSent = WXAPiHandler.wxApi?.openWXApp()?:false
if ("openWXApp" == call.method) {
val isSent = WXAPiHandler.wxApi?.openWXApp() ?: false
result.success(isSent)
return
}
......
......@@ -16,7 +16,6 @@
package com.jarvan.fluwx.handler
import android.util.Log
import com.tencent.mm.opensdk.diffdev.DiffDevOAuthFactory
import com.tencent.mm.opensdk.diffdev.OAuthErrCode
import com.tencent.mm.opensdk.diffdev.OAuthListener
......@@ -34,8 +33,8 @@ internal class FluwxAuthHandler(private val methodChannel: MethodChannel) {
object : OAuthListener {
override fun onAuthFinish(p0: OAuthErrCode, authCode: String?) {
methodChannel.invokeMethod("onAuthByQRCodeFinished", mapOf(
"errCode" to p0.code,
"authCode" to authCode
"errCode" to p0.code,
"authCode" to authCode
))
}
......@@ -73,7 +72,7 @@ internal class FluwxAuthHandler(private val methodChannel: MethodChannel) {
val signature = call.argument("signature") ?: ""
// val schemeData = call.argument("schemeData")?:""
result.success(qrCodeAuth.auth(appId, scope, nonceStr, timeStamp, signature, qrCodeAuthListener))
result.success(qrCodeAuth.auth(appId, scope, nonceStr, timeStamp, signature, qrCodeAuthListener))
}
......@@ -81,7 +80,7 @@ internal class FluwxAuthHandler(private val methodChannel: MethodChannel) {
result.success(qrCodeAuth.stopAuth())
}
fun removeAllListeners(){
fun removeAllListeners() {
qrCodeAuth.removeAllListeners()
}
......
......@@ -3,13 +3,13 @@ package com.jarvan.fluwx.handler
import com.tencent.mm.opensdk.modelbiz.WXOpenBusinessWebview
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import java.util.HashMap
import java.util.*
class FluwxAutoDeductHandler {
fun signAutoDeduct(call: MethodCall, result: MethodChannel.Result) {
val appId:String = call.argument<String>("appid") ?: ""
val appId: String = call.argument<String>("appid") ?: ""
val mchId = call.argument<String>("mch_id") ?: ""
val planId = call.argument<String>("plan_id") ?: ""
val contractCode = call.argument<String>("contract_code") ?: ""
......@@ -20,9 +20,9 @@ class FluwxAutoDeductHandler {
val sign = call.argument<String>("sign") ?: ""
val timestamp = call.argument<String>("timestamp") ?: ""
val returnApp = call.argument<String>("return_app") ?: ""
val businessType = call.argument<Int>("businessType")?:12
val businessType = call.argument<Int>("businessType") ?: 12
val map = HashMap<String,String>()
val map = HashMap<String, String>()
map["appid"] = appId
map["mch_id"] = mchId
map["plan_id"] = planId
......
......@@ -25,7 +25,7 @@ object FluwxRequestHandler {
registrar = reg
}
fun getRegistrar():PluginRegistry.Registrar?{
fun getRegistrar(): PluginRegistry.Registrar? {
return registrar;
}
......
......@@ -133,7 +133,7 @@ object FluwxResponseHandler {
}
private fun handlerWXOpenBusinessWebviewResponse(response:WXOpenBusinessWebview.Resp){
private fun handlerWXOpenBusinessWebviewResponse(response: WXOpenBusinessWebview.Resp) {
val result = mapOf(
WechatPluginKeys.PLATFORM to WechatPluginKeys.ANDROID,
errCode to response.errCode,
......
......@@ -168,8 +168,8 @@ internal class FluwxShareHandler {
private suspend fun getThumbnailByteArray(imageData: ByteArray): ByteArray {
return GlobalScope.async(Dispatchers.Default, CoroutineStart.DEFAULT) {
val bitmap = BitmapFactory.decodeByteArray(imageData,0,imageData.size)
val bmp = ThumbnailCompressUtil.createScaledBitmapWithRatio(bitmap,WeChatThumbnailUtil.SHARE_IMAGE_THUMB_LENGTH,false)
val bitmap = BitmapFactory.decodeByteArray(imageData, 0, imageData.size)
val bmp = ThumbnailCompressUtil.createScaledBitmapWithRatio(bitmap, WeChatThumbnailUtil.SHARE_IMAGE_THUMB_LENGTH, false)
if (bmp == null) {
byteArrayOf()
} else {
......@@ -190,24 +190,22 @@ internal class FluwxShareHandler {
}
val imgObj = if (byteArray != null && byteArray.isNotEmpty()) {
if (byteArray.size > 512 * 1024){
if (byteArray.size > 512 * 1024) {
val input = ByteArrayInputStream(byteArray)
val suffix = when {
val suffix = when {
imagePath.isNullOrBlank() -> ".jpeg"
imagePath.lastIndexOf(".") == -1 -> ".jpeg"
else -> imagePath.substring(imagePath.lastIndexOf("."))
}
val file = ShareImageUtil.inputStreamToFile(input,suffix,registrar!!.context())
val file = ShareImageUtil.inputStreamToFile(input, suffix, registrar!!.context())
WXImageObject().apply {
setImagePath(file.absolutePath)
}
}else{
} else {
WXImageObject(byteArray)
}
......
......@@ -15,24 +15,19 @@
*/
package com.jarvan.fluwx.utils;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import com.jarvan.fluwx.constant.WeChatPluginImageSchema;
import com.jarvan.fluwx.constant.WechatPluginKeys;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
......@@ -134,9 +129,9 @@ public class ShareImageUtil {
File externalFile = context.getExternalCacheDir();
if (externalFile == null) {
return null;
return null;
}
file = new File(externalFile.getAbsolutePath()+File.separator+UUID.randomUUID().toString()+suffix);
file = new File(externalFile.getAbsolutePath() + File.separator + UUID.randomUUID().toString() + suffix);
// file = File.createTempFile(UUID.randomUUID().toString(), suffix);
......@@ -177,11 +172,9 @@ public class ShareImageUtil {
}
private static InputStream openStream(String url) {
if(!url.startsWith("https") && !url.startsWith("http")){
url = "http://"+url;
if (!url.startsWith("https") && !url.startsWith("http")) {
url = "http://" + url;
}
OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
Request request = new Request.Builder().url(url).get().build();
......
......@@ -84,7 +84,7 @@ public class WeChatThumbnailUtil {
public static byte[] thumbnailForCommon(String thumbnail, PluginRegistry.Registrar registrar) {
File file;
if(thumbnail == null || thumbnail.isEmpty()) {
if (thumbnail == null || thumbnail.isEmpty()) {
return null;
} else if (thumbnail.startsWith(WeChatPluginImageSchema.SCHEMA_ASSETS)) {
file = getAssetFile(thumbnail, registrar);
......@@ -227,8 +227,8 @@ public class WeChatThumbnailUtil {
private static File downloadImage(String url) {
if(!url.startsWith("https") && !url.startsWith("http")){
url = "http://"+url;
if (!url.startsWith("https") && !url.startsWith("http")) {
url = "http://" + url;
}
File result = null;
......
......@@ -62,7 +62,7 @@ open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
// FIXME: 可能是官方的Bug,从微信拉起APP的Intent类型不对,无法跳转回Flutter Activity
// 稳定复现场景:微信版本为7.0.5,小程序SDK为2.7.7
val activity = FluwxRequestHandler.getRegistrar()?.activity()
if (baseReq.type == 4 && activity is Activity){
if (baseReq.type == 4 && activity is Activity) {
// com.tencent.mm.opensdk.constants.ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX = 4
startActivity(Intent(this, activity::class.java))
finish()
......
......@@ -5,7 +5,6 @@
#import "FluwxPaymentHandler.h"
#import "FluwxMethods.h"
#import "FluwxKeys.h"
#import "FluwxWXApiHandler.h"
#import "FluwxShareHandler.h"
#import "FluwxLaunchMiniProgramHandler.h"
......
......@@ -7,5 +7,6 @@
extern NSString *const resultDone;
extern NSString *const resultErrorNeedWeChat;
extern NSString *const resultMessageNeedWeChat;
@interface CallResults : NSObject
@end
\ No newline at end of file
......@@ -7,6 +7,7 @@
NSString *const resultDone = @"done";
NSString *const resultErrorNeedWeChat = @"wxapi not configured";
NSString *const resultMessageNeedWeChat = @"please config wxapi first";
@implementation CallResults {
}
......
......@@ -19,14 +19,14 @@ NSString *const fluwxKeyDescription = @"description";
NSString *const fluwxKeyPackage = @"?package=";
NSString *const fluwxKeyMessageExt =@"messageExt";
NSString *const fluwxKeyMessageExt = @"messageExt";
NSString *const fluwxKeyMediaTagName = @"mediaTagName ";
NSString *const fluwxKeyMessageAction = @"messageAction";
NSString *const fluwxKeyPlatform = @"platform";
NSString *const fluwxKeyIOS=@"iOS";
NSString *const fluwxKeyIOS = @"iOS";
NSString *const fluwxKeyResult=@"result";
NSString *const fluwxKeyResult = @"result";
@implementation FluwxKeys {
......
......@@ -14,6 +14,7 @@ NSString *const shareVideo = @"shareVideo";
NSString *const shareWebPage = @"shareWebPage";
NSString *const shareMiniProgram = @"shareMiniProgram";
NSString *const LaunchMiniProgram = @"launchMiniProgram";
@implementation FluwxMethods {
......
......@@ -11,7 +11,7 @@ WechatAuthSDK *_qrauth;
FlutterMethodChannel *_fluwxMethodChannel = nil;
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar methodChannel:(FlutterMethodChannel *)flutterMethodChannel {
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar methodChannel:(FlutterMethodChannel *)flutterMethodChannel {
self = [super init];
if (self) {
_qrauth = [[WechatAuthSDK alloc] init];
......@@ -39,7 +39,7 @@ FlutterMethodChannel *_fluwxMethodChannel = nil;
NSString *signature = call.arguments[@"signature"];
NSString *schemeData = (call.arguments[@"schemeData"] == (id) [NSNull null]) ? nil : call.arguments[@"schemeData"];
BOOL done = [_qrauth Auth:appId nonceStr:nonceStr timeStamp:timeStamp scope:scope signature:signature schemeData:schemeData];
BOOL done = [_qrauth Auth:appId nonceStr:nonceStr timeStamp:timeStamp scope:scope signature:signature schemeData:schemeData];
result(@(done));
}
......@@ -53,7 +53,7 @@ FlutterMethodChannel *_fluwxMethodChannel = nil;
}
- (void)onAuthGotQrcode:(UIImage *)image {
NSData * imageData = UIImagePNGRepresentation(image);
NSData *imageData = UIImagePNGRepresentation(image);
// if (imageData == nil) {
// imageData = UIImageJPEGRepresentation(image, 1);
// }
......@@ -62,9 +62,9 @@ FlutterMethodChannel *_fluwxMethodChannel = nil;
}
- (void)onAuthFinish:(int)errCode AuthCode:(nullable NSString *)authCode {
NSDictionary *errorCode = @{@"errCode":@(errCode)};
NSDictionary *errorCode = @{@"errCode": @(errCode)};
NSMutableDictionary *result = [NSMutableDictionary dictionaryWithDictionary:errorCode];
if(authCode != nil){
if (authCode != nil) {
result[@"authCode"] = authCode;
}
[_fluwxMethodChannel invokeMethod:@"onAuthByQRCodeFinished" arguments:result];
......
......@@ -19,39 +19,38 @@
return self;
}
-(void)handleAutoDeductWithCall:(FlutterMethodCall *)call result:(FlutterResult)result {
- (void)handleAutoDeductWithCall:(FlutterMethodCall *)call result:(FlutterResult)result {
NSDictionary *params = call.arguments;
NSMutableDictionary *paramsFromDart = [NSMutableDictionary dictionaryWithDictionary:call.arguments];
[paramsFromDart removeObjectForKey:@"businessType"];
WXOpenBusinessWebViewReq *req = [[WXOpenBusinessWebViewReq alloc] init];
NSNumber * businessType = call.arguments[@"businessType"];
NSNumber *businessType = call.arguments[@"businessType"];
req.businessType = [businessType unsignedIntValue];
req.queryInfoDic = paramsFromDart;
BOOL b = [WXApi sendReq:req];
result(@(b));
}
-(NSString *)convertToJsonData:(NSDictionary *)dict
{
- (NSString *)convertToJsonData:(NSDictionary *)dict {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
NSString *jsonString;
if (!jsonData) {
NSLog(@"%@",error);
}else{
jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"%@", error);
} else {
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
// NSRange range = {0,jsonString.length};
// //去掉字符串中的空格
// [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
NSRange range2 = {0,mutStr.length};
NSRange range2 = {0, mutStr.length};
//去掉字符串中的换行符
[mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
return mutStr;
}
......
......@@ -20,15 +20,15 @@
NSNumber *typeInt = call.arguments[@"miniProgramType"];
WXMiniProgramType miniProgramType = WXMiniProgramTypeRelease;
if([typeInt isEqualToNumber:@1]){
miniProgramType =WXMiniProgramTypeTest;
} else if([typeInt isEqualToNumber:@2]){
if ([typeInt isEqualToNumber:@1]) {
miniProgramType = WXMiniProgramTypeTest;
} else if ([typeInt isEqualToNumber:@2]) {
miniProgramType = WXMiniProgramTypePreview;
}
BOOL done = [WXApiRequestHandler launchMiniProgramWithUserName:userName
path:path
type:miniProgramType];
BOOL done = [WXApiRequestHandler launchMiniProgramWithUserName:userName
path:path
type:miniProgramType];
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
}
@end
......@@ -3,16 +3,12 @@
//
#import "FluwxPaymentHandler.h"
#import "ThumbnailHelper.h"
#import "NSStringWrapper.h"
#import "CallResults.h"
#import "FluwxKeys.h"
#import "StringToWeChatScene.h"
#import "FluwxMethods.h"
@implementation FluwxPaymentHandler
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
self = [super init];
return self;
......@@ -27,10 +23,9 @@
}
NSNumber *timestamp = call.arguments[@"timeStamp"];
NSNumber * timestamp = call.arguments[@"timeStamp"];
NSString *partnerId = call.arguments[@"partnerId"];
NSString *partnerId = call.arguments[@"partnerId"];
NSString *prepayId = call.arguments[@"prepayId"];
NSString *packageValue = call.arguments[@"packageValue"];
NSString *nonceStr = call.arguments[@"nonceStr"];
......
......@@ -53,7 +53,7 @@ NSObject <FlutterPluginRegistrar> *_registrar;
[self shareMusic:call result:result];
} else if ([shareVideo isEqualToString:call.method]) {
[self shareVideo:call result:result];
} else if([shareMiniProgram isEqualToString:call.method]){
} else if ([shareMiniProgram isEqualToString:call.method]) {
[self shareMiniProgram:call result:result];
}
......@@ -70,7 +70,7 @@ NSObject <FlutterPluginRegistrar> *_registrar;
- (void)shareImage:(FlutterMethodCall *)call result:(FlutterResult)result {
NSString *imagePath = call.arguments[fluwxKeyImage];
if ([StringUtil isBlank:imagePath]) {
NSData *imageData = ((FlutterStandardTypedData)call.arguments[fluwxKeyImageData]).data;
NSData *imageData = ((FlutterStandardTypedData) call.arguments[fluwxKeyImageData]).data;
[self shareMemoryImage:call result:result imageData:imageData];
} else if ([imagePath hasPrefix:SCHEMA_ASSETS]) {
[self shareAssetImage:call result:result imagePath:imagePath];
......@@ -96,8 +96,8 @@ NSObject <FlutterPluginRegistrar> *_registrar;
dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
dispatch_async(globalQueue, ^{
if(thumbnailImage == nil)
if (thumbnailImage == nil)
*thumbnailImage = [self getThumbnail:thumbnail size:32 * 1024];
......@@ -110,9 +110,9 @@ NSObject <FlutterPluginRegistrar> *_registrar;
Action:call.arguments[fluwxKeyMessageAction]
ThumbImage:thumbnailImage
InScene:[StringToWeChatScene toScene:scene]
title:call.arguments[fluwxKeyTitle]
title:call.arguments[fluwxKeyTitle]
description:call.arguments[fluwxKeyDescription]
];
];
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
});
......@@ -152,9 +152,9 @@ NSObject <FlutterPluginRegistrar> *_registrar;
Action:call.arguments[fluwxKeyMessageAction]
ThumbImage:thumbnailImage
InScene:[StringToWeChatScene toScene:scene]
title:call.arguments[fluwxKeyTitle]
title:call.arguments[fluwxKeyTitle]
description:call.arguments[fluwxKeyDescription]
];
];
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
});
......@@ -209,7 +209,6 @@ NSObject <FlutterPluginRegistrar> *_registrar;
}
- (void)shareAssetImage:(FlutterMethodCall *)call result:(FlutterResult)result imagePath:(NSString *)imagePath {
......@@ -236,14 +235,14 @@ NSObject <FlutterPluginRegistrar> *_registrar;
// Action:fluwxKeyMessageAction
// ThumbImage:thumbnailImage
// InScene:[StringToWeChatScene toScene:scene]];
BOOL done = [WXApiRequestHandler sendImageData:imageData
TagName:call.arguments[fluwxKeyMediaTagName]
MessageExt:call.arguments[fluwxKeyMessageExt]
Action:call.arguments[fluwxKeyMessageAction]
ThumbImage:thumbnailImage
InScene:[StringToWeChatScene toScene:scene]
title:call.arguments[fluwxKeyTitle]
description:call.arguments[fluwxKeyDescription]];
BOOL done = [WXApiRequestHandler sendImageData:imageData
TagName:call.arguments[fluwxKeyMediaTagName]
MessageExt:call.arguments[fluwxKeyMessageExt]
Action:call.arguments[fluwxKeyMessageAction]
ThumbImage:thumbnailImage
InScene:[StringToWeChatScene toScene:scene]
title:call.arguments[fluwxKeyTitle]
description:call.arguments[fluwxKeyDescription]];
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(done)});
});
......@@ -347,7 +346,7 @@ NSObject <FlutterPluginRegistrar> *_registrar;
}
- (void)shareMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result {
dispatch_queue_t globalQueue = dispatch_get_global_queue(0,0);
dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
dispatch_async(globalQueue, ^{
NSString *thumbnail = call.arguments[fluwxKeyThumbnail];
......@@ -382,9 +381,9 @@ NSObject <FlutterPluginRegistrar> *_registrar;
NSNumber *typeInt = call.arguments[@"miniProgramType"];
WXMiniProgramType miniProgramType = WXMiniProgramTypeRelease;
if([typeInt isEqualToNumber:@1]){
miniProgramType =WXMiniProgramTypeTest;
} else if([typeInt isEqualToNumber:@2]){
if ([typeInt isEqualToNumber:@1]) {
miniProgramType = WXMiniProgramTypeTest;
} else if ([typeInt isEqualToNumber:@2]) {
miniProgramType = WXMiniProgramTypePreview;
}
......
......@@ -30,7 +30,7 @@
isWeChatRegistered = [WXApi registerApp:appId enableMTA:[call.arguments[@"enableMTA"] boolValue]];
UInt64 typeFlag = MMAPP_SUPPORT_TEXT | MMAPP_SUPPORT_PICTURE | MMAPP_SUPPORT_LOCATION | MMAPP_SUPPORT_VIDEO |MMAPP_SUPPORT_AUDIO | MMAPP_SUPPORT_WEBPAGE | MMAPP_SUPPORT_DOC | MMAPP_SUPPORT_DOCX | MMAPP_SUPPORT_PPT | MMAPP_SUPPORT_PPTX | MMAPP_SUPPORT_XLS | MMAPP_SUPPORT_XLSX | MMAPP_SUPPORT_PDF;
UInt64 typeFlag = MMAPP_SUPPORT_TEXT | MMAPP_SUPPORT_PICTURE | MMAPP_SUPPORT_LOCATION | MMAPP_SUPPORT_VIDEO | MMAPP_SUPPORT_AUDIO | MMAPP_SUPPORT_WEBPAGE | MMAPP_SUPPORT_DOC | MMAPP_SUPPORT_DOCX | MMAPP_SUPPORT_PPT | MMAPP_SUPPORT_PPTX | MMAPP_SUPPORT_XLS | MMAPP_SUPPORT_XLSX | MMAPP_SUPPORT_PDF;
[WXApi registerAppSupportContentFlag:typeFlag];
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(isWeChatRegistered)});
}
......@@ -39,7 +39,7 @@
if (!isWeChatRegistered) {
result([FlutterError errorWithCode:resultErrorNeedWeChat message:@"please config wxapi first" details:nil]);
return;
}else{
} else {
result(@([WXApi isWXAppInstalled]));
}
}
......
......@@ -7,11 +7,13 @@
//
#import <Foundation/Foundation.h>
#define JavaNotFound -1
@interface NSString(Wrapper)
@interface NSString (Wrapper)
/** Return the char value at the specified index. */
- (unichar) charAt:(int)index;
- (unichar)charAt:(int)index;
/**
* Compares two strings lexicographically.
......@@ -19,46 +21,46 @@
* a value less than 0 if this string is lexicographically less than the string argument;
* and a value greater than 0 if this string is lexicographically greater than the string argument.
*/
- (int) compareTo:(NSString*) anotherString;
- (int)compareTo:(NSString *)anotherString;
- (int) compareToIgnoreCase:(NSString*) str;
- (int)compareToIgnoreCase:(NSString *)str;
- (BOOL) contains:(NSString*) str;
- (BOOL)contains:(NSString *)str;
- (BOOL) startsWith:(NSString*)prefix;
- (BOOL)startsWith:(NSString *)prefix;
- (BOOL) endsWith:(NSString*)suffix;
- (BOOL)endsWith:(NSString *)suffix;
- (BOOL) equals:(NSString*) anotherString;
- (BOOL)equals:(NSString *)anotherString;
- (BOOL) equalsIgnoreCase:(NSString*) anotherString;
- (BOOL)equalsIgnoreCase:(NSString *)anotherString;
- (int) indexOfChar:(unichar)ch;
- (int)indexOfChar:(unichar)ch;
- (int) indexOfChar:(unichar)ch fromIndex:(int)index;
- (int)indexOfChar:(unichar)ch fromIndex:(int)index;
- (int) indexOfString:(NSString*)str;
- (int)indexOfString:(NSString *)str;
- (int) indexOfString:(NSString*)str fromIndex:(int)index;
- (int)indexOfString:(NSString *)str fromIndex:(int)index;
- (int) lastIndexOfChar:(unichar)ch;
- (int)lastIndexOfChar:(unichar)ch;
- (int) lastIndexOfChar:(unichar)ch fromIndex:(int)index;
- (int)lastIndexOfChar:(unichar)ch fromIndex:(int)index;
- (int) lastIndexOfString:(NSString*)str;
- (int)lastIndexOfString:(NSString *)str;
- (int) lastIndexOfString:(NSString*)str fromIndex:(int)index;
- (int)lastIndexOfString:(NSString *)str fromIndex:(int)index;
- (NSString *) substringFromIndex:(int)beginIndex toIndex:(int)endIndex;
- (NSString *)substringFromIndex:(int)beginIndex toIndex:(int)endIndex;
- (NSString *) toLowerCase;
- (NSString *)toLowerCase;
- (NSString *) toUpperCase;
- (NSString *)toUpperCase;
- (NSString *) trim;
- (NSString *)trim;
- (NSString *) replaceAll:(NSString*)origin with:(NSString*)replacement;
- (NSString *)replaceAll:(NSString *)origin with:(NSString *)replacement;
- (NSArray *) split:(NSString*) separator;
- (NSArray *)split:(NSString *)separator;
@end
......@@ -8,12 +8,11 @@
#import "NSStringWrapper.h"
@implementation NSString(Wrapper)
@implementation NSString (Wrapper)
/** Java-like method. Returns the char value at the specified index. */
- (unichar) charAt:(int)index {
- (unichar)charAt:(int)index {
return [self characterAtIndex:index];
}
......@@ -23,42 +22,42 @@
* a value less than 0 if this string is lexicographically less than the string argument;
* and a value greater than 0 if this string is lexicographically greater than the string argument.
*/
- (int) compareTo:(NSString*) anotherString {
- (int)compareTo:(NSString *)anotherString {
return [self compare:anotherString];
}
/** Java-like method. Compares two strings lexicographically, ignoring case differences. */
- (int) compareToIgnoreCase:(NSString*) str {
- (int)compareToIgnoreCase:(NSString *)str {
return [self compare:str options:NSCaseInsensitiveSearch];
}
/** Java-like method. Returns true if and only if this string contains the specified sequence of char values. */
- (BOOL) contains:(NSString*) str {
- (BOOL)contains:(NSString *)str {
NSRange range = [self rangeOfString:str];
return (range.location != NSNotFound);
}
- (BOOL) startsWith:(NSString*)prefix {
- (BOOL)startsWith:(NSString *)prefix {
return [self hasPrefix:prefix];
}
- (BOOL) endsWith:(NSString*)suffix {
- (BOOL)endsWith:(NSString *)suffix {
return [self hasSuffix:suffix];
}
- (BOOL) equals:(NSString*) anotherString {
- (BOOL)equals:(NSString *)anotherString {
return [self isEqualToString:anotherString];
}
- (BOOL) equalsIgnoreCase:(NSString*) anotherString {
- (BOOL)equalsIgnoreCase:(NSString *)anotherString {
return [[self toLowerCase] equals:[anotherString toLowerCase]];
}
- (int) indexOfChar:(unichar)ch{
- (int)indexOfChar:(unichar)ch {
return [self indexOfChar:ch fromIndex:0];
}
- (int) indexOfChar:(unichar)ch fromIndex:(int)index{
- (int)indexOfChar:(unichar)ch fromIndex:(int)index {
int len = self.length;
for (int i = index; i < len; ++i) {
if (ch == [self charAt:i]) {
......@@ -68,7 +67,7 @@
return JavaNotFound;
}
- (int) indexOfString:(NSString*)str {
- (int)indexOfString:(NSString *)str {
NSRange range = [self rangeOfString:str];
if (range.location == NSNotFound) {
return JavaNotFound;
......@@ -76,7 +75,7 @@
return range.location;
}
- (int) indexOfString:(NSString*)str fromIndex:(int)index {
- (int)indexOfString:(NSString *)str fromIndex:(int)index {
NSRange fromRange = NSMakeRange(index, self.length - index);
NSRange range = [self rangeOfString:str options:NSLiteralSearch range:fromRange];
if (range.location == NSNotFound) {
......@@ -85,9 +84,9 @@
return range.location;
}
- (int) lastIndexOfChar:(unichar)ch {
- (int)lastIndexOfChar:(unichar)ch {
int len = self.length;
for (int i = len-1; i >=0; --i) {
for (int i = len - 1; i >= 0; --i) {
if ([self charAt:i] == ch) {
return i;
}
......@@ -95,7 +94,7 @@
return JavaNotFound;
}
- (int) lastIndexOfChar:(unichar)ch fromIndex:(int)index {
- (int)lastIndexOfChar:(unichar)ch fromIndex:(int)index {
int len = self.length;
if (index >= len) {
index = len - 1;
......@@ -108,7 +107,7 @@
return JavaNotFound;
}
- (int) lastIndexOfString:(NSString*)str {
- (int)lastIndexOfString:(NSString *)str {
NSRange range = [self rangeOfString:str options:NSBackwardsSearch];
if (range.location == NSNotFound) {
return JavaNotFound;
......@@ -116,7 +115,7 @@
return range.location;
}
- (int) lastIndexOfString:(NSString*)str fromIndex:(int)index {
- (int)lastIndexOfString:(NSString *)str fromIndex:(int)index {
NSRange fromRange = NSMakeRange(0, index);
NSRange range = [self rangeOfString:str options:NSBackwardsSearch range:fromRange];
if (range.location == NSNotFound) {
......@@ -125,7 +124,7 @@
return range.location;
}
- (NSString *) substringFromIndex:(int)beginIndex toIndex:(int)endIndex {
- (NSString *)substringFromIndex:(int)beginIndex toIndex:(int)endIndex {
if (endIndex <= beginIndex) {
return @"";
}
......@@ -133,23 +132,23 @@
return [self substringWithRange:range];
}
- (NSString *) toLowerCase {
- (NSString *)toLowerCase {
return [self lowercaseString];
}
- (NSString *) toUpperCase {
- (NSString *)toUpperCase {
return [self uppercaseString];
}
- (NSString *) trim {
- (NSString *)trim {
return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
- (NSString *) replaceAll:(NSString*)origin with:(NSString*)replacement {
- (NSString *)replaceAll:(NSString *)origin with:(NSString *)replacement {
return [self stringByReplacingOccurrencesOfString:origin withString:replacement];
}
- (NSArray *) split:(NSString*) separator {
- (NSArray *)split:(NSString *)separator {
return [self componentsSeparatedByString:separator];
}
......
......@@ -6,5 +6,5 @@
#import "WXApiObject.h"
@interface StringToWeChatScene : NSObject
+ (enum WXScene) toScene : (NSString *) string;
+ (enum WXScene)toScene:(NSString *)string;
@end
......@@ -6,11 +6,11 @@
@implementation StringToWeChatScene
+ (enum WXScene) toScene:(NSString *)string {
+ (enum WXScene)toScene:(NSString *)string {
if ([string isEqualToString:@"WeChatScene.TIMELINE"]) {
return WXSceneTimeline;
}else if ([string isEqualToString:@"WeChatScene.FAVORITE"]) {
} else if ([string isEqualToString:@"WeChatScene.FAVORITE"]) {
return WXSceneFavorite;
} else {
return WXSceneSession;
......
......@@ -6,6 +6,7 @@
@interface StringUtil : NSObject
+ (BOOL) isBlank:(NSString *)string;
+ (NSString *) nilToEmpty:(NSString *) string;
+ (BOOL)isBlank:(NSString *)string;
+ (NSString *)nilToEmpty:(NSString *)string;
@end
\ No newline at end of file
......@@ -7,7 +7,7 @@
@implementation StringUtil
+ (BOOL) isBlank:(NSString *)string {
+ (BOOL)isBlank:(NSString *)string {
if (string == nil) {
......@@ -26,6 +26,6 @@
}
+ (NSString *)nilToEmpty:(NSString *)string {
return string == nil?@"":string;
return string == nil ? @"" : string;
}
@end
\ No newline at end of file
......@@ -7,7 +7,7 @@
@implementation ThumbnailHelper
+ (UIImage *)compressImage:(UIImage *)image toByte:(NSUInteger)maxLength isPNG:(BOOL) isPNG{
+ (UIImage *)compressImage:(UIImage *)image toByte:(NSUInteger)maxLength isPNG:(BOOL)isPNG {
// Compress by quality
CGFloat compression = 1;
NSData *data = UIImageJPEGRepresentation(image, compression);
......@@ -27,8 +27,8 @@
}
}
UIImage *resultImage ;
if(isPNG){
UIImage *resultImage;
if (isPNG) {
NSData *tmp = UIImagePNGRepresentation([UIImage imageWithData:data]);
resultImage = [UIImage imageWithData:tmp];
} else {
......@@ -42,9 +42,9 @@
NSUInteger lastDataLength = 0;
while (data.length > maxLength && data.length != lastDataLength) {
lastDataLength = data.length;
CGFloat ratio = (CGFloat)maxLength / data.length;
CGSize size = CGSizeMake((NSUInteger)(resultImage.size.width * sqrtf(ratio)),
(NSUInteger)(resultImage.size.height * sqrtf(ratio))); // Use NSUInteger to prevent white blank
CGFloat ratio = (CGFloat) maxLength / data.length;
CGSize size = CGSizeMake((NSUInteger) (resultImage.size.width * sqrtf(ratio)),
(NSUInteger) (resultImage.size.height * sqrtf(ratio))); // Use NSUInteger to prevent white blank
UIGraphicsBeginImageContext(size);
[resultImage drawInRect:CGRectMake(0, 0, size.width, size.height)];
resultImage = UIGraphicsGetImageFromCurrentImageContext();
......@@ -56,34 +56,33 @@
}
- (UIImage*)scaleFromImage:(UIImage*)image width:(CGSize)newSize {
- (UIImage *)scaleFromImage:(UIImage *)image width:(CGSize)newSize {
CGSize imageSize = image.size;
CGFloat width = imageSize.width;
CGFloat height = imageSize.height;
if (width <= newSize.width && height <= newSize.height){
if (width <= newSize.width && height <= newSize.height) {
return image;
}
if (width == 0 || height == 0){
if (width == 0 || height == 0) {
return image;
}
CGFloat widthFactor = newSize.width / width;
CGFloat heightFactor = newSize.height / height;
CGFloat scaleFactor = (widthFactor<heightFactor?widthFactor:heightFactor);
CGFloat scaleFactor = (widthFactor < heightFactor ? widthFactor : heightFactor);
CGFloat scaledWidth = width * scaleFactor;
CGFloat scaledHeight = height * scaleFactor;
CGSize targetSize = CGSizeMake(scaledWidth,scaledHeight);
CGSize targetSize = CGSizeMake(scaledWidth, scaledHeight);
UIGraphicsBeginImageContext(targetSize);
[image drawInRect:CGRectMake(0,0,scaledWidth,scaledHeight)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
[image drawInRect:CGRectMake(0, 0, scaledWidth, scaledHeight)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
@end
\ No newline at end of file
......@@ -12,8 +12,11 @@
@class StringUtil;
@interface FluwxAuthHandler : NSObject <WechatAuthAPIDelegate>
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar methodChannel:(FlutterMethodChannel *)flutterMethodChannel;
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar methodChannel:(FlutterMethodChannel *)flutterMethodChannel;
- (void)handleAuth:(FlutterMethodCall *)call result:(FlutterResult)result;
- (void)authByQRCode:(FlutterMethodCall *)call result:(FlutterResult)result;
-(void) stopAuthByQRCode:(FlutterMethodCall *)call result:(FlutterResult)result;
- (void)stopAuthByQRCode:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
......@@ -11,8 +11,9 @@
NS_ASSUME_NONNULL_BEGIN
@interface FluwxAutoDeductHandler : NSObject
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar;
-(void)handleAutoDeductWithCall:(FlutterMethodCall *)call result:(FlutterResult)result;
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar;
- (void)handleAutoDeductWithCall:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
NS_ASSUME_NONNULL_END
......@@ -6,6 +6,7 @@
@class StringUtil;
@interface FluwxLaunchMiniProgramHandler : NSObject
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar;
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar;
- (void)handleLaunchMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
\ No newline at end of file
......@@ -7,10 +7,12 @@
#import "FluwxPlugin.h"
#import "WXApiRequestHandler.h"
#import "WXApi.h"
@class StringUtil;
@interface FluwxPaymentHandler : NSObject
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar;
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar;
- (void)handlePayment:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
......@@ -16,14 +16,11 @@
#import <Flutter/Flutter.h>
extern BOOL isWeChatRegistered;
extern BOOL handleOpenURLByFluwx;
@interface FluwxPlugin : NSObject<FlutterPlugin> {
@interface FluwxPlugin : NSObject <FlutterPlugin> {
}
......
......@@ -11,6 +11,7 @@
#import "WXApiObject.h"
#import "WXApi.h"
@protocol WXApiManagerDelegate <NSObject>
@optional
......@@ -44,12 +45,12 @@
- (void)managerDidRecvPaymentResponse:(PayResp *)response;
@end
@interface FluwxResponseHandler : NSObject<WXApiDelegate>
@interface FluwxResponseHandler : NSObject <WXApiDelegate>
@property (nonatomic, assign) id<WXApiManagerDelegate> delegate;
@property(nonatomic, assign) id <WXApiManagerDelegate> delegate;
+ (instancetype)defaultManager;
- (void) setMethodChannel:(FlutterMethodChannel *) flutterMethodChannel;
- (void)setMethodChannel:(FlutterMethodChannel *)flutterMethodChannel;
@end
......@@ -7,9 +7,11 @@
#import <Flutter/Flutter.h>
#import "FluwxPlugin.h"
#import "WXApiRequestHandler.h"
@class StringUtil;
@interface FluwxShareHandler : NSObject
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar;
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar;
- (void)handleShare:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
......@@ -11,8 +11,9 @@
NS_ASSUME_NONNULL_BEGIN
@interface FluwxSubscribeMsgHandler : NSObject
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar;
-(void)handleSubscribeWithCall:(FlutterMethodCall *)call result:(FlutterResult)result;
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar;
- (void)handleSubscribeWithCall:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
NS_ASSUME_NONNULL_END
......@@ -6,8 +6,8 @@
#import <Flutter/Flutter.h>
@interface FluwxWXApiHandler : NSObject
- (void)registerApp:(FlutterMethodCall *)call result:(FlutterResult)result;
- (void)checkWeChatInstallation:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
\ No newline at end of file
......@@ -12,6 +12,7 @@
NS_ASSUME_NONNULL_BEGIN
#pragma mark - WXApiDelegate
/*! @brief 接收并处理来自微信终端程序的事件消息
*
* 接收并处理来自微信终端程序的事件消息,期间微信界面会切换到第三方应用程序。
......@@ -26,8 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
* 可能收到的请求有GetMessageFromWXReq、ShowMessageFromWXReq等。
* @param req 具体请求内容,是自动释放的
*/
- (void)onReq:(BaseReq*)req;
- (void)onReq:(BaseReq *)req;
/*! @brief 发送一个sendReq后,收到微信的回应
......@@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
* 可能收到的处理结果有SendMessageToWXResp、SendAuthResp等。
* @param resp具体的回应内容,是自动释放的
*/
- (void)onResp:(BaseResp*)resp;
- (void)onResp:(BaseResp *)resp;
@end
......@@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol WXApiLogDelegate <NSObject>
- (void)onLog:(NSString*)log logLevel:(WXLogLevel)level;
- (void)onLog:(NSString *)log logLevel:(WXLogLevel)level;
@end
......@@ -88,7 +88,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)registerAppSupportContentFlag:(UInt64)typeFlag;
/*! @brief 处理微信通过URL启动App时传递的数据
*
* 需要在 application:openURL:sourceApplication:annotation:或者application:handleOpenURL中调用。
......@@ -96,8 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param delegate WXApiDelegate对象,用来接收微信触发的消息。
* @return 成功返回YES,失败返回NO。
*/
+ (BOOL)handleOpenURL:(NSURL *)url delegate:(nullable id<WXApiDelegate>)delegate;
+ (BOOL)handleOpenURL:(NSURL *)url delegate:(nullable id <WXApiDelegate>)delegate;
/*! @brief 检查微信是否已被用户安装
......@@ -107,7 +105,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)isWXAppInstalled;
/*! @brief 判断当前微信的版本是否支持OpenApi
*
* @return 支持返回YES,不支持返回NO。
......@@ -115,7 +112,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)isWXAppSupportApi;
/*! @brief 获取微信的itunes安装地址
*
* @return 微信的安装地址字符串。
......@@ -123,7 +119,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)getWXAppInstallUrl;
/*! @brief 获取当前微信SDK的版本号
*
* @return 返回当前微信SDK的版本号
......@@ -131,7 +126,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)getApiVersion;
/*! @brief 打开微信
*
* @return 成功返回YES,失败返回NO。
......@@ -139,7 +133,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)openWXApp;
/*! @brief 发送请求到微信,等待微信返回onResp
*
* 函数调用后,会切换到微信的界面。第三方应用程序等待微信返回onResp。微信在异步处理完成后一定会调用onResp。支持以下类型
......@@ -147,7 +140,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param req 具体的发送请求,在调用函数后,请自己释放。
* @return 成功返回YES,失败返回NO。
*/
+ (BOOL)sendReq:(BaseReq*)req;
+ (BOOL)sendReq:(BaseReq *)req;
/*! @brief 发送Auth请求到微信,支持用户没安装微信,等待微信返回onResp
*
......@@ -157,7 +150,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param delegate WXApiDelegate对象,用来接收微信触发的消息。
* @return 成功返回YES,失败返回NO。
*/
+ (BOOL)sendAuthReq:(SendAuthReq*)req viewController:(UIViewController*)viewController delegate:(nullable id<WXApiDelegate>)delegate;
+ (BOOL)sendAuthReq:(SendAuthReq *)req viewController:(UIViewController *)viewController delegate:(nullable id <WXApiDelegate>)delegate;
/*! @brief 收到微信onReq的请求,发送对应的应答给微信,并切换到微信界面
......@@ -167,7 +160,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param resp 具体的应答内容,调用函数后,请自己释放
* @return 成功返回YES,失败返回NO。
*/
+ (BOOL)sendResp:(BaseResp*)resp;
+ (BOOL)sendResp:(BaseResp *)resp;
/*! @brief WXApi的成员函数,接受微信的log信息。byBlock
......@@ -185,7 +178,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param level 打印log的级别
* @param logDelegate 打印log的回调代理,
*/
+ (void)startLogByLevel:(WXLogLevel)level logDelegate:(id<WXApiLogDelegate>)logDelegate;
+ (void)startLogByLevel:(WXLogLevel)level logDelegate:(id <WXApiLogDelegate>)logDelegate;
/*! @brief 停止打印log,会清理block或者delegate为空,释放block
* @param
......
......@@ -14,24 +14,23 @@ NS_ASSUME_NONNULL_BEGIN
/*! @brief 错误码
*
*/
enum WXErrCode {
WXSuccess = 0, /**< 成功 */
WXErrCodeCommon = -1, /**< 普通错误类型 */
enum WXErrCode {
WXSuccess = 0, /**< 成功 */
WXErrCodeCommon = -1, /**< 普通错误类型 */
WXErrCodeUserCancel = -2, /**< 用户点击取消并返回 */
WXErrCodeSentFail = -3, /**< 发送失败 */
WXErrCodeAuthDeny = -4, /**< 授权失败 */
WXErrCodeUnsupport = -5, /**< 微信不支持 */
WXErrCodeSentFail = -3, /**< 发送失败 */
WXErrCodeAuthDeny = -4, /**< 授权失败 */
WXErrCodeUnsupport = -5, /**< 微信不支持 */
};
/*! @brief 请求发送场景
*
*/
enum WXScene {
WXSceneSession = 0, /**< 聊天界面 */
WXSceneTimeline = 1, /**< 朋友圈 */
WXSceneFavorite = 2, /**< 收藏 */
WXSceneSession = 0, /**< 聊天界面 */
WXSceneTimeline = 1, /**< 朋友圈 */
WXSceneFavorite = 2, /**< 收藏 */
WXSceneSpecifiedSession = 3, /**< 指定联系人 */
};
......@@ -41,7 +40,6 @@ enum WXAPISupport {
};
/*! @brief 跳转profile类型
*
*/
......@@ -67,33 +65,32 @@ enum WXMPWebviewType {
};
/*! @brief 应用支持接收微信的文件类型
*
*/
typedef NS_ENUM(UInt64, enAppSupportContentFlag) {
MMAPP_SUPPORT_NOCONTENT = 0x0,
MMAPP_SUPPORT_TEXT = 0x1,
MMAPP_SUPPORT_PICTURE = 0x2,
MMAPP_SUPPORT_LOCATION = 0x4,
MMAPP_SUPPORT_VIDEO = 0x8,
MMAPP_SUPPORT_AUDIO = 0x10,
MMAPP_SUPPORT_WEBPAGE = 0x20,
MMAPP_SUPPORT_TEXT = 0x1,
MMAPP_SUPPORT_PICTURE = 0x2,
MMAPP_SUPPORT_LOCATION = 0x4,
MMAPP_SUPPORT_VIDEO = 0x8,
MMAPP_SUPPORT_AUDIO = 0x10,
MMAPP_SUPPORT_WEBPAGE = 0x20,
// Suport File Type
MMAPP_SUPPORT_DOC = 0x40, // doc
MMAPP_SUPPORT_DOC = 0x40, // doc
MMAPP_SUPPORT_DOCX = 0x80, // docx
MMAPP_SUPPORT_PPT = 0x100, // ppt
MMAPP_SUPPORT_PPT = 0x100, // ppt
MMAPP_SUPPORT_PPTX = 0x200, // pptx
MMAPP_SUPPORT_XLS = 0x400, // xls
MMAPP_SUPPORT_XLS = 0x400, // xls
MMAPP_SUPPORT_XLSX = 0x800, // xlsx
MMAPP_SUPPORT_PDF = 0x1000, // pdf
MMAPP_SUPPORT_PDF = 0x1000, // pdf
};
/*! @brief log的级别
*
*/
typedef NS_ENUM(NSInteger,WXLogLevel) {
typedef NS_ENUM(NSInteger, WXLogLevel) {
WXLogLevelNormal = 0, // 打印日常的日志
WXLogLevelDetail = 1, // 打印详细的日志
};
......@@ -105,36 +102,36 @@ typedef NS_ENUM(NSInteger,WXLogLevel) {
typedef void(^WXLogBolock)(NSString *log);
#pragma mark - BaseReq
/*! @brief 该类为微信终端SDK所有请求类的基类
*
*/
@interface BaseReq : NSObject
/** 请求类型 */
@property (nonatomic, assign) int type;
@property(nonatomic, assign) int type;
/** 由用户微信号和AppID组成的唯一标识,发送请求时第三方程序必须填写,用于校验微信用户是否换号登录*/
@property (nonatomic, copy) NSString *openID;
@property(nonatomic, copy) NSString *openID;
@end
#pragma mark - BaseResp
/*! @brief 该类为微信终端SDK所有响应类的基类
*
*/
@interface BaseResp : NSObject
/** 错误码 */
@property (nonatomic, assign) int errCode;
@property(nonatomic, assign) int errCode;
/** 错误提示字符串 */
@property (nonatomic, copy) NSString *errStr;
@property(nonatomic, copy) NSString *errStr;
/** 响应类型 */
@property (nonatomic, assign) int type;
@property(nonatomic, assign) int type;
@end
#pragma mark - WXMediaMessage
@class WXMediaMessage;
......@@ -148,22 +145,23 @@ typedef void(^WXLogBolock)(NSString *log);
@interface PayReq : BaseReq
/** 商家向财付通申请的商家id */
@property (nonatomic, copy) NSString *partnerId;
@property(nonatomic, copy) NSString *partnerId;
/** 预支付订单 */
@property (nonatomic, copy) NSString *prepayId;
@property(nonatomic, copy) NSString *prepayId;
/** 随机串,防重发 */
@property (nonatomic, copy) NSString *nonceStr;
@property(nonatomic, copy) NSString *nonceStr;
/** 时间戳,防重发 */
@property (nonatomic, assign) UInt32 timeStamp;
@property(nonatomic, assign) UInt32 timeStamp;
/** 商家根据财付通文档填写的数据和签名 */
@property (nonatomic, copy) NSString *package;
@property(nonatomic, copy) NSString *package;
/** 商家根据微信开放平台文档对数据做的签名 */
@property (nonatomic, copy) NSString *sign;
@property(nonatomic, copy) NSString *sign;
@end
#pragma mark - PayResp
/*! @brief 微信终端返回给第三方的关于支付结果的结构体
*
* 微信终端返回给第三方的关于支付结果的结构体
......@@ -171,12 +169,13 @@ typedef void(^WXLogBolock)(NSString *log);
@interface PayResp : BaseResp
/** 财付通返回给商家的信息 */
@property (nonatomic, copy) NSString *returnKey;
@property(nonatomic, copy) NSString *returnKey;
@end
#pragma mark - WXOfflinePay
/*! @brief 第三方向微信终端发起离线支付
*
* 第三方向微信终端发起离线支付的消息结构体
......@@ -196,8 +195,8 @@ typedef void(^WXLogBolock)(NSString *log);
#endif
#pragma mark - SendAuthReq
/*! @brief 第三方程序向微信终端请求认证的消息结构
*
* 第三方程序要向微信申请认证,并请求某些权限,需要调用WXApi的sendReq成员函数,
......@@ -209,14 +208,15 @@ typedef void(^WXLogBolock)(NSString *log);
* @see SendAuthResp
* @note scope字符串长度不能超过1K
*/
@property (nonatomic, copy) NSString *scope;
@property(nonatomic, copy) NSString *scope;
/** 第三方程序本身用来标识其请求的唯一性,最后跳转回第三方程序时,由微信终端回传。
* @note state字符串长度不能超过1K
*/
@property (nonatomic, copy) NSString *state;
@property(nonatomic, copy) NSString *state;
@end
#pragma mark - SendAuthResp
/*! @brief 微信处理完第三方程序的认证和权限申请后向第三方程序回送的处理结果。
*
* 第三方程序要向微信申请认证,并请求某些权限,需要调用WXApi的sendReq成员函数,向微信终端发送一个SendAuthReq消息结构。
......@@ -224,18 +224,18 @@ typedef void(^WXLogBolock)(NSString *log);
* @see onResp
*/
@interface SendAuthResp : BaseResp
@property (nonatomic, copy, nullable) NSString *code;
@property(nonatomic, copy, nullable) NSString *code;
/** 第三方程序发送时用来标识其请求的唯一性的标志,由第三方程序调用sendReq时传入,由微信终端回传
* @note state字符串长度不能超过1K
*/
@property (nonatomic, copy, nullable) NSString *state;
@property (nonatomic, copy, nullable) NSString *lang;
@property (nonatomic, copy, nullable) NSString *country;
@property(nonatomic, copy, nullable) NSString *state;
@property(nonatomic, copy, nullable) NSString *lang;
@property(nonatomic, copy, nullable) NSString *country;
@end
#pragma mark - SendMessageToWXReq
/*! @brief 第三方程序发送消息至微信终端程序的消息结构体
*
* 第三方程序向微信发送信息需要传入SendMessageToWXReq结构体,信息类型包括文本消息和多媒体消息,
......@@ -246,24 +246,25 @@ typedef void(^WXLogBolock)(NSString *log);
/** 发送消息的文本内容
* @note 文本长度必须大于0且小于10K
*/
@property (nonatomic, copy) NSString *text;
@property(nonatomic, copy) NSString *text;
/** 发送消息的多媒体内容
* @see WXMediaMessage
*/
@property (nonatomic, strong) WXMediaMessage *message;
@property(nonatomic, strong) WXMediaMessage *message;
/** 发送消息的类型,包括文本消息和多媒体消息两种,两者只能选择其一,不能同时发送文本和多媒体消息 */
@property (nonatomic, assign) BOOL bText;
@property(nonatomic, assign) BOOL bText;
/** 发送的目标场景,可以选择发送到会话(WXSceneSession)或者朋友圈(WXSceneTimeline)。 默认发送到会话。
* @see WXScene
*/
@property (nonatomic, assign) int scene;
@property(nonatomic, assign) int scene;
/** 指定发送消息的人
* @note WXSceneSpecifiedSession时有效
*/
@property (nonatomic, copy, nullable) NSString *toUserOpenId;
@property(nonatomic, copy, nullable) NSString *toUserOpenId;
@end
#pragma mark - SendMessageToWXResp
/*! @brief 微信终端向第三方程序返回的SendMessageToWXReq处理结果。
*
* 第三方程序向微信终端发送SendMessageToWXReq后,微信发送回来的处理结果,该结果用SendMessageToWXResp表示。
......@@ -274,21 +275,21 @@ typedef void(^WXLogBolock)(NSString *log);
@end
#pragma mark - GetMessageFromWXReq
/*! @brief 微信终端向第三方程序请求提供内容的消息结构体。
*
* 微信终端向第三方程序请求提供内容,微信终端会向第三方程序发送GetMessageFromWXReq消息结构体,
* 需要第三方程序调用sendResp返回一个GetMessageFromWXResp消息结构体。
*/
@interface GetMessageFromWXReq : BaseReq
@property (nonatomic, strong) NSString *lang;
@property (nonatomic, strong) NSString *country;
@property(nonatomic, strong) NSString *lang;
@property(nonatomic, strong) NSString *country;
@end
#pragma mark - GetMessageFromWXResp
/*! @brief 微信终端向第三方程序请求提供内容,第三方程序向微信终端返回的消息结构体。
*
* 微信终端向第三方程序请求提供内容,第三方程序调用sendResp向微信终端返回一个GetMessageFromWXResp消息结构体。
......@@ -297,18 +298,18 @@ typedef void(^WXLogBolock)(NSString *log);
/** 向微信终端提供的文本内容
@note 文本长度必须大于0且小于10K
*/
@property (nonatomic, strong) NSString *text;
@property(nonatomic, strong) NSString *text;
/** 向微信终端提供的多媒体内容。
* @see WXMediaMessage
*/
@property (nonatomic, strong) WXMediaMessage *message;
@property(nonatomic, strong) WXMediaMessage *message;
/** 向微信终端提供内容的消息类型,包括文本消息和多媒体消息两种,两者只能选择其一,不能同时发送文本和多媒体消息 */
@property (nonatomic, assign) BOOL bText;
@property(nonatomic, assign) BOOL bText;
@end
#pragma mark - ShowMessageFromWXReq
/*! @brief 微信通知第三方程序,要求第三方程序显示的消息结构体。
*
* 微信需要通知第三方程序显示或处理某些内容时,会向第三方程序发送ShowMessageFromWXReq消息结构体。
......@@ -318,14 +319,14 @@ typedef void(^WXLogBolock)(NSString *log);
/** 微信终端向第三方程序发送的要求第三方程序处理的多媒体内容
* @see WXMediaMessage
*/
@property (nonatomic, strong) WXMediaMessage *message;
@property (nonatomic, copy) NSString *lang;
@property (nonatomic, copy) NSString *country;
@property(nonatomic, strong) WXMediaMessage *message;
@property(nonatomic, copy) NSString *lang;
@property(nonatomic, copy) NSString *country;
@end
#pragma mark - ShowMessageFromWXResp
/*! @brief 微信通知第三方程序,要求第三方程序显示或处理某些消息,第三方程序处理完后向微信终端发送的处理结果。
*
* 微信需要通知第三方程序显示或处理某些内容时,会向第三方程序发送ShowMessageFromWXReq消息结构体。
......@@ -336,19 +337,20 @@ typedef void(^WXLogBolock)(NSString *log);
#pragma mark - LaunchFromWXReq
/*! @brief 微信终端打开第三方程序携带的消息结构体
*
* 微信向第三方发送的结构体,第三方不需要返回
*/
@interface LaunchFromWXReq : BaseReq
@property (nonatomic, strong) WXMediaMessage *message;
@property (nonatomic, copy) NSString *lang;
@property (nonatomic, copy) NSString *country;
@property(nonatomic, strong) WXMediaMessage *message;
@property(nonatomic, copy) NSString *lang;
@property(nonatomic, copy) NSString *country;
@end
#pragma mark - OpenTempSessionReq
/* ! @brief 第三方通知微信,打开临时会话
*
* 第三方通知微信,打开临时会话
......@@ -357,14 +359,15 @@ typedef void(^WXLogBolock)(NSString *log);
/** 需要打开的用户名
* @attention 长度不能超过512字节
*/
@property (nonatomic, copy) NSString *username;
@property(nonatomic, copy) NSString *username;
/** 开发者自定义参数,拉起临时会话后会发给开发者后台,可以用于识别场景
* @attention 长度不能超过32位
*/
@property (nonatomic, copy) NSString *sessionFrom;
@property(nonatomic, copy) NSString *sessionFrom;
@end
#pragma mark - OpenTempSessionResp
/*! @brief 微信终端向第三方程序返回的OpenTempSessionReq处理结果。
*
* 第三方程序向微信终端发送OpenTempSessionReq后,微信发送回来的处理结果,该结果用OpenTempSessionResp表示。
......@@ -374,8 +377,8 @@ typedef void(^WXLogBolock)(NSString *log);
@end
#pragma mark - OpenWebviewReq
/* ! @brief 第三方通知微信启动内部浏览器,打开指定网页
*
* 第三方通知微信启动内部浏览器,打开指定Url对应的网页
......@@ -389,6 +392,7 @@ typedef void(^WXLogBolock)(NSString *log);
@end
#pragma mark - OpenWebviewResp
/*! @brief 微信终端向第三方程序返回的OpenWebviewReq处理结果
*
* 第三方程序向微信终端发送OpenWebviewReq后,微信发送回来的处理结果,该结果用OpenWebviewResp表示
......@@ -398,8 +402,8 @@ typedef void(^WXLogBolock)(NSString *log);
@end
#pragma mark - WXOpenBusinessWebViewReq
/*! @brief 第三方通知微信启动内部浏览器,打开指定业务的网页
*
*
......@@ -409,16 +413,17 @@ typedef void(^WXLogBolock)(NSString *log);
/** 网页业务类型
* @attention
*/
@property (nonatomic, assign) UInt32 businessType;
@property(nonatomic, assign) UInt32 businessType;
/** 网页业务参数
* @attention
*/
@property (nonatomic, strong, nullable) NSDictionary *queryInfoDic;
@property(nonatomic, strong, nullable) NSDictionary *queryInfoDic;
@end
#pragma mark - WXOpenBusinessWebViewResp
/*! @brief 微信终端向第三方程序返回的WXOpenBusinessWebViewResp处理结果。
*
* 第三方程序向微信终端发送WXOpenBusinessWebViewReq后,微信发送回来的处理结果,该结果用WXOpenBusinessWebViewResp表示。
......@@ -427,17 +432,18 @@ typedef void(^WXLogBolock)(NSString *log);
/** 第三方程序自定义简单数据,微信终端会回传给第三方程序处理
* @attention 长度不能超过2k
*/
@property (nonatomic, copy) NSString *result;
@property(nonatomic, copy) NSString *result;
/** 网页业务类型
* @attention
*/
@property (nonatomic, assign) UInt32 businessType;
@property(nonatomic, assign) UInt32 businessType;
@end
#pragma mark - OpenRankListReq
/* ! @brief 第三方通知微信,打开硬件排行榜
*
* 第三方通知微信,打开硬件排行榜
......@@ -447,6 +453,7 @@ typedef void(^WXLogBolock)(NSString *log);
@end
#pragma mark - OpenRanklistResp
/*! @brief 微信终端向第三方程序返回的OpenRankListReq处理结果。
*
* 第三方程序向微信终端发送OpenRankListReq后,微信发送回来的处理结果,该结果用OpenRankListResp表示。
......@@ -456,8 +463,8 @@ typedef void(^WXLogBolock)(NSString *log);
@end
#pragma mark - JumpToBizProfileReq
/* ! @brief 第三方通知微信,打开指定微信号profile页面
*
* 第三方通知微信,打开指定微信号profile页面
......@@ -466,21 +473,21 @@ typedef void(^WXLogBolock)(NSString *log);
/** 跳转到该公众号的profile
* @attention 长度不能超过512字节
*/
@property (nonatomic, copy) NSString *username;
@property(nonatomic, copy) NSString *username;
/** 如果用户加了该公众号为好友,extMsg会上传到服务器
* @attention 长度不能超过1024字节
*/
@property (nonatomic, copy, nullable) NSString *extMsg;
@property(nonatomic, copy, nullable) NSString *extMsg;
/**
* 跳转的公众号类型
* @see WXBizProfileType
*/
@property (nonatomic, assign) int profileType;
@property(nonatomic, assign) int profileType;
@end
#pragma mark - JumpToBizWebviewReq
/* ! @brief 第三方通知微信,打开指定usrname的profile网页版
*
*/
......@@ -506,23 +513,23 @@ typedef void(^WXLogBolock)(NSString *log);
/** 卡id
* @attention 长度不能超过1024字节
*/
@property (nonatomic, copy) NSString *cardId;
@property(nonatomic, copy) NSString *cardId;
/** ext信息
* @attention 长度不能超过2024字节
*/
@property (nonatomic, copy, nullable) NSString *extMsg;
@property(nonatomic, copy, nullable) NSString *extMsg;
/**
* @attention 卡的状态,req不需要填。resp:0为未添加,1为已添加。
*/
@property (nonatomic, assign) UInt32 cardState;
@property(nonatomic, assign) UInt32 cardState;
/**
* @attention req不需要填,chooseCard返回的。
*/
@property (nonatomic, copy) NSString *encryptCode;
@property(nonatomic, copy) NSString *encryptCode;
/**
* @attention req不需要填,chooseCard返回的。
*/
@property (nonatomic, copy) NSString *appID;
@property(nonatomic, copy) NSString *appID;
@end;
#pragma mark - WXInvoiceItem
......@@ -531,27 +538,28 @@ typedef void(^WXLogBolock)(NSString *log);
/** 卡id
* @attention 长度不能超过1024字节
*/
@property (nonatomic, copy) NSString *cardId;
@property(nonatomic, copy) NSString *cardId;
/** ext信息
* @attention 长度不能超过2024字节
*/
@property (nonatomic, copy, nullable) NSString *extMsg;
@property(nonatomic, copy, nullable) NSString *extMsg;
/**
* @attention 卡的状态,req不需要填。resp:0为未添加,1为已添加。
*/
@property (nonatomic, assign) UInt32 cardState;
@property(nonatomic, assign) UInt32 cardState;
/**
* @attention req不需要填,chooseCard返回的。
*/
@property (nonatomic, copy) NSString *encryptCode;
@property(nonatomic, copy) NSString *encryptCode;
/**
* @attention req不需要填,chooseCard返回的。
*/
@property (nonatomic, copy) NSString *appID;
@property(nonatomic, copy) NSString *appID;
@end
#pragma mark - AddCardToWXCardPackageReq
/* ! @brief 请求添加卡券至微信卡包
*
*/
......@@ -560,12 +568,13 @@ typedef void(^WXLogBolock)(NSString *log);
/** 卡列表
* @attention 个数不能超过40个 类型WXCardItem
*/
@property (nonatomic, strong) NSArray *cardAry;
@property(nonatomic, strong) NSArray *cardAry;
@end
#pragma mark - AddCardToWXCardPackageResp
/** ! @brief 微信返回第三方添加卡券结果
*
*/
......@@ -574,85 +583,93 @@ typedef void(^WXLogBolock)(NSString *log);
/** 卡列表
* @attention 个数不能超过40个 类型WXCardItem
*/
@property (nonatomic, strong) NSArray *cardAry;
@property(nonatomic, strong) NSArray *cardAry;
@end
#pragma mark - WXChooseCardReq
/* ! @brief 请求从微信选取卡券
*
*/
@interface WXChooseCardReq : BaseReq
@property (nonatomic, copy) NSString *appID;
@property (nonatomic, assign) UInt32 shopID;
@property (nonatomic, assign) UInt32 canMultiSelect;
@property (nonatomic, copy) NSString *cardType;
@property (nonatomic, copy) NSString *cardTpID;
@property (nonatomic, copy) NSString *signType;
@property (nonatomic, copy) NSString *cardSign;
@property (nonatomic, assign) UInt32 timeStamp;
@property (nonatomic, copy) NSString *nonceStr;
@property(nonatomic, copy) NSString *appID;
@property(nonatomic, assign) UInt32 shopID;
@property(nonatomic, assign) UInt32 canMultiSelect;
@property(nonatomic, copy) NSString *cardType;
@property(nonatomic, copy) NSString *cardTpID;
@property(nonatomic, copy) NSString *signType;
@property(nonatomic, copy) NSString *cardSign;
@property(nonatomic, assign) UInt32 timeStamp;
@property(nonatomic, copy) NSString *nonceStr;
@end
#pragma mark - WXChooseCardResp
/** ! @brief 微信返回第三方请求选择卡券结果
*
*/
@interface WXChooseCardResp : BaseResp
@property (nonatomic, strong ) NSArray* cardAry;
@property(nonatomic, strong) NSArray *cardAry;
@end
#pragma mark - WXChooseInvoiceReq
/* ! @brief 请求从微信选取发票
*
*/
@interface WXChooseInvoiceReq : BaseReq
@property (nonatomic, copy) NSString *appID;
@property (nonatomic, assign) UInt32 shopID;
@property (nonatomic, copy) NSString *signType;
@property (nonatomic, copy) NSString *cardSign;
@property (nonatomic, assign) UInt32 timeStamp;
@property (nonatomic, copy) NSString *nonceStr;
@property(nonatomic, copy) NSString *appID;
@property(nonatomic, assign) UInt32 shopID;
@property(nonatomic, copy) NSString *signType;
@property(nonatomic, copy) NSString *cardSign;
@property(nonatomic, assign) UInt32 timeStamp;
@property(nonatomic, copy) NSString *nonceStr;
@end
#pragma mark - WXChooseInvoiceResp
/** ! @brief 微信返回第三方请求选择发票结果
*
*/
@interface WXChooseInvoiceResp : BaseResp
@property (nonatomic, strong) NSArray* cardAry;
@property(nonatomic, strong) NSArray *cardAry;
@end
#pragma mark - WXSubscriptionReq
@interface WXSubscribeMsgReq : BaseReq
@property (nonatomic, assign) UInt32 scene;
@property (nonatomic, copy) NSString *templateId;
@property (nonatomic, copy, nullable) NSString *reserved;
@property(nonatomic, assign) UInt32 scene;
@property(nonatomic, copy) NSString *templateId;
@property(nonatomic, copy, nullable) NSString *reserved;
@end
#pragma mark - WXSubscriptionReq
@interface WXSubscribeMsgResp : BaseResp
@property (nonatomic, copy) NSString *templateId;
@property (nonatomic, assign) UInt32 scene;
@property (nonatomic, copy) NSString *action;
@property (nonatomic, copy) NSString *reserved;
@property (nonatomic, copy, nullable) NSString *openId;
@property(nonatomic, copy) NSString *templateId;
@property(nonatomic, assign) UInt32 scene;
@property(nonatomic, copy) NSString *action;
@property(nonatomic, copy) NSString *reserved;
@property(nonatomic, copy, nullable) NSString *openId;
@end
#pragma mark - WXSubscribeMiniProgramMsg
/** ! @brief 微信返回第三方请求选择发票结果
*
*/
@interface WXSubscribeMiniProgramMsgReq : BaseReq
@property (nonatomic, copy) NSString *miniProgramAppid;
@property(nonatomic, copy) NSString *miniProgramAppid;
@end
#pragma mark - WXSubscriptionReq
@interface WXSubscribeMiniProgramMsgResp : BaseResp
@property(nonatomic, copy) NSString *openId; // 小程序openid
......@@ -662,9 +679,10 @@ typedef void(^WXLogBolock)(NSString *log);
@end
#pragma mark - WXinvoiceAuthInsertReq
@interface WXInvoiceAuthInsertReq : BaseReq
@property (nonatomic, copy) NSString *urlString;
@property(nonatomic, copy) NSString *urlString;
@end
......@@ -672,35 +690,39 @@ typedef void(^WXLogBolock)(NSString *log);
@interface WXInvoiceAuthInsertResp : BaseResp
@property (nonatomic, copy) NSString *wxOrderId;
@property(nonatomic, copy) NSString *wxOrderId;
@end
#pragma mark - WXNontaxPayReq
@interface WXNontaxPayReq:BaseReq
@property (nonatomic, copy) NSString *urlString;
@interface WXNontaxPayReq : BaseReq
@property(nonatomic, copy) NSString *urlString;
@end
#pragma mark - WXNontaxPayResp
@interface WXNontaxPayResp : BaseResp
@property (nonatomic, copy) NSString *wxOrderId;
@property(nonatomic, copy) NSString *wxOrderId;
@end
#pragma mark - WXPayInsuranceReq
@interface WXPayInsuranceReq : BaseReq
@property (nonatomic, copy) NSString *urlString;
@property(nonatomic, copy) NSString *urlString;
@end
#pragma mark - WXPayInsuranceResp
@interface WXPayInsuranceResp : BaseResp
@property (nonatomic, copy) NSString *wxOrderId;
@property(nonatomic, copy) NSString *wxOrderId;
@end
......@@ -717,28 +739,28 @@ typedef void(^WXLogBolock)(NSString *log);
/** 标题
* @note 长度不能超过512字节
*/
@property (nonatomic, copy) NSString *title;
@property(nonatomic, copy) NSString *title;
/** 描述内容
* @note 长度不能超过1K
*/
@property (nonatomic, copy) NSString *description;
@property(nonatomic, copy) NSString *description;
/** 缩略图数据
* @note 大小不能超过32K
*/
@property (nonatomic, strong, nullable) NSData *thumbData;
@property(nonatomic, strong, nullable) NSData *thumbData;
/**
* @note 长度不能超过64字节
*/
@property (nonatomic, copy, nullable) NSString *mediaTagName;
@property(nonatomic, copy, nullable) NSString *mediaTagName;
/**
*
*/
@property (nonatomic, copy, nullable) NSString *messageExt;
@property (nonatomic, copy, nullable) NSString *messageAction;
@property(nonatomic, copy, nullable) NSString *messageExt;
@property(nonatomic, copy, nullable) NSString *messageAction;
/**
* 多媒体数据对象,可以为WXImageObject,WXMusicObject,WXVideoObject,WXWebpageObject等。
*/
@property (nonatomic, strong) id mediaObject;
@property(nonatomic, strong) id mediaObject;
/*! @brief 设置消息缩略图的方法
*
......@@ -750,8 +772,8 @@ typedef void(^WXLogBolock)(NSString *log);
@end
#pragma mark - WXImageObject
/*! @brief 多媒体消息中包含的图片数据对象
*
* 微信终端和第三方程序之间传递消息中包含的图片数据对象。
......@@ -768,12 +790,13 @@ typedef void(^WXLogBolock)(NSString *log);
/** 图片真实数据内容
* @note 大小不能超过25M
*/
@property (nonatomic, strong) NSData *imageData;
@property(nonatomic, strong) NSData *imageData;
@end
#pragma mark - WXMusicObject
/*! @brief 多媒体消息中包含的音乐数据对象
*
* 微信终端和第三方程序之间传递消息中包含的音乐数据对象。
......@@ -790,26 +813,26 @@ typedef void(^WXLogBolock)(NSString *log);
/** 音乐网页的url地址
* @note 长度不能超过10K
*/
@property (nonatomic, copy) NSString *musicUrl;
@property(nonatomic, copy) NSString *musicUrl;
/** 音乐lowband网页的url地址
* @note 长度不能超过10K
*/
@property (nonatomic, copy) NSString *musicLowBandUrl;
@property(nonatomic, copy) NSString *musicLowBandUrl;
/** 音乐数据url地址
* @note 长度不能超过10K
*/
@property (nonatomic, copy) NSString *musicDataUrl;
@property(nonatomic, copy) NSString *musicDataUrl;
/**音乐lowband数据url地址
* @note 长度不能超过10K
*/
@property (nonatomic, copy) NSString *musicLowBandDataUrl;
@property(nonatomic, copy) NSString *musicLowBandDataUrl;
@end
#pragma mark - WXVideoObject
/*! @brief 多媒体消息中包含的视频数据对象
*
* 微信终端和第三方程序之间传递消息中包含的视频数据对象。
......@@ -826,17 +849,17 @@ typedef void(^WXLogBolock)(NSString *log);
/** 视频网页的url地址
* @note 长度不能超过10K
*/
@property (nonatomic, copy) NSString *videoUrl;
@property(nonatomic, copy) NSString *videoUrl;
/** 视频lowband网页的url地址
* @note 长度不能超过10K
*/
@property (nonatomic, copy) NSString *videoLowBandUrl;
@property(nonatomic, copy) NSString *videoLowBandUrl;
@end
#pragma mark - WXWebpageObject
/*! @brief 多媒体消息中包含的网页数据对象
*
* 微信终端和第三方程序之间传递消息中包含的网页数据对象。
......@@ -852,13 +875,13 @@ typedef void(^WXLogBolock)(NSString *log);
/** 网页的url地址
* @note 不能为空且长度不能超过10K
*/
@property (nonatomic, copy) NSString *webpageUrl;
@property(nonatomic, copy) NSString *webpageUrl;
@end
#pragma mark - WXAppExtendObject
/*! @brief 多媒体消息中包含的App扩展数据对象
*
* 第三方程序向微信终端发送包含WXAppExtendObject的多媒体消息,
......@@ -876,21 +899,21 @@ typedef void(^WXLogBolock)(NSString *log);
/** 若第三方程序不存在,微信终端会打开该url所指的App下载地址
* @note 长度不能超过10K
*/
@property (nonatomic, copy) NSString *url;
@property(nonatomic, copy) NSString *url;
/** 第三方程序自定义简单数据,微信终端会回传给第三方程序处理
* @note 长度不能超过2K
*/
@property (nonatomic, copy, nullable) NSString *extInfo;
@property(nonatomic, copy, nullable) NSString *extInfo;
/** App文件数据,该数据发送给微信好友,微信好友需要点击后下载数据,微信终端会回传给第三方程序处理
* @note 大小不能超过10M
*/
@property (nonatomic, strong, nullable) NSData *fileData;
@property(nonatomic, strong, nullable) NSData *fileData;
@end
#pragma mark - WXEmoticonObject
/*! @brief 多媒体消息中包含的表情数据对象
*
* 微信终端和第三方程序之间传递消息中包含的表情数据对象。
......@@ -907,13 +930,13 @@ typedef void(^WXLogBolock)(NSString *log);
/** 表情真实数据内容
* @note 大小不能超过10M
*/
@property (nonatomic, strong) NSData *emoticonData;
@property(nonatomic, strong) NSData *emoticonData;
@end
#pragma mark - WXFileObject
/*! @brief 多媒体消息中包含的文件数据对象
*
* @see WXMediaMessage
......@@ -929,17 +952,18 @@ typedef void(^WXLogBolock)(NSString *log);
/** 文件后缀名
* @note 长度不超过64字节
*/
@property (nonatomic, copy) NSString *fileExtension;
@property(nonatomic, copy) NSString *fileExtension;
/** 文件真实数据内容
* @note 大小不能超过10M
*/
@property (nonatomic, strong) NSData *fileData;
@property(nonatomic, strong) NSData *fileData;
@end
#pragma mark - WXLocationObject
/*! @brief 多媒体消息中包含的地理位置数据对象
*
* 微信终端和第三方程序之间传递消息中包含的地理位置数据对象。
......@@ -956,12 +980,13 @@ typedef void(^WXLogBolock)(NSString *log);
/** 地理位置信息
* @note 经纬度
*/
@property (nonatomic, assign) double lng; //经度
@property (nonatomic, assign) double lat; //纬度
@property(nonatomic, assign) double lng; //经度
@property(nonatomic, assign) double lat; //纬度
@end
#pragma mark - WXTextObject
/*! @brief 多媒体消息中包含的文本数据对象
*
* 微信终端和第三方程序之间传递消息中包含的文本数据对象。
......@@ -978,7 +1003,7 @@ typedef void(^WXLogBolock)(NSString *log);
/** 地理位置信息
* @note 文本内容
*/
@property (nonatomic, copy) NSString *contentText;
@property(nonatomic, copy) NSString *contentText;
@end
......@@ -995,28 +1020,28 @@ typedef void(^WXLogBolock)(NSString *log);
/** 低版本网页链接
* @attention 长度不能超过1024字节
*/
@property (nonatomic, copy) NSString *webpageUrl;
@property(nonatomic, copy) NSString *webpageUrl;
/** 小程序username */
@property (nonatomic, copy) NSString *userName;
@property(nonatomic, copy) NSString *userName;
/** 小程序页面的路径
* @attention 不填默认拉起小程序首页
*/
@property (nonatomic, copy, nullable) NSString *path;
@property(nonatomic, copy, nullable) NSString *path;
/** 小程序新版本的预览图
* @attention 大小不能超过128k
*/
@property (nonatomic, strong, nullable) NSData *hdImageData;
@property(nonatomic, strong, nullable) NSData *hdImageData;
/** 是否使用带 shareTicket 的转发 */
@property (nonatomic, assign) BOOL withShareTicket;
@property(nonatomic, assign) BOOL withShareTicket;
/** 分享小程序的版本
* @attention (正式,开发,体验)
*/
@property (nonatomic, assign) WXMiniProgramType miniProgramType;
@property(nonatomic, assign) WXMiniProgramType miniProgramType;
@end
......@@ -1031,37 +1056,39 @@ typedef void(^WXLogBolock)(NSString *log);
+ (WXLaunchMiniProgramReq *)object;
/** 小程序username */
@property (nonatomic, copy) NSString *userName;
@property(nonatomic, copy) NSString *userName;
/** 小程序页面的路径
* @attention 不填默认拉起小程序首页
*/
@property (nonatomic, copy, nullable) NSString *path;
@property(nonatomic, copy, nullable) NSString *path;
/** 分享小程序的版本
* @attention (正式,开发,体验)
*/
@property (nonatomic, assign) WXMiniProgramType miniProgramType;
@property(nonatomic, assign) WXMiniProgramType miniProgramType;
/** ext信息
* @attention json格式
*/
@property (nonatomic, copy, nullable) NSString *extMsg;
@property(nonatomic, copy, nullable) NSString *extMsg;
@end
#pragma mark - WXLaunchMiniProgramResp
/*! @brief 微信终端向第三方程序返回的WXLaunchMiniProgramReq处理结果。
*
* 第三方程序向微信终端发送WXLaunchMiniProgramReq后,微信发送回来的处理结果,该结果用WXLaunchMiniProgramResp表示。
*/
@interface WXLaunchMiniProgramResp : BaseResp
@property (nonatomic, copy, nullable) NSString *extMsg;
@property(nonatomic, copy, nullable) NSString *extMsg;
@end
#pragma mark - WXOpenBusinessViewReq
/*! @brief WXOpenBusinessViewReq对象, 可实现第三方通知微信启动,打开业务页面
*
* @note 返回的WXOpenBusinessViewReq对象是自动释放的
......@@ -1073,16 +1100,16 @@ typedef void(^WXLogBolock)(NSString *log);
/** 业务类型
*/
@property (nonatomic, copy) NSString *businessType;
@property(nonatomic, copy) NSString *businessType;
/** 业务参数
*/
@property (nonatomic, copy, nullable) NSString *query;
@property(nonatomic, copy, nullable) NSString *query;
/** ext信息
* @note 选填,json格式
*/
@property (nonatomic, copy, nullable) NSString *extInfo;
@property(nonatomic, copy, nullable) NSString *extInfo;
@end
......@@ -1091,11 +1118,12 @@ typedef void(^WXLogBolock)(NSString *log);
/** 业务类型
*/
@property (nonatomic, copy) NSString *businessType;
@property(nonatomic, copy) NSString *businessType;
/** 业务返回数据
*/
@property (nonatomic, copy, nullable) NSString *extMsg;
@property(nonatomic, copy, nullable) NSString *extMsg;
@end
NS_ASSUME_NONNULL_END
......@@ -131,11 +131,11 @@
timestamp:(UInt32)timestamp;
+ (BOOL) sendPayment:(NSString *)appId
PartnerId:(NSString *)partnerId
PrepayId:(NSString *)prepayId
NonceStr:(NSString *)nonceStr
Timestamp:(UInt32)timestamp
Package:(NSString *)package
Sign:(NSString *)sign;
+ (BOOL)sendPayment:(NSString *)appId
PartnerId:(NSString *)partnerId
PrepayId:(NSString *)prepayId
NonceStr:(NSString *)nonceStr
Timestamp:(UInt32)timestamp
Package:(NSString *)package
Sign:(NSString *)sign;
@end
......@@ -11,7 +11,7 @@
NS_ASSUME_NONNULL_BEGIN
enum AuthErrCode {
enum AuthErrCode {
WechatAuth_Err_Ok = 0, //Auth成功
WechatAuth_Err_NormalErr = -1, //普通错误
WechatAuth_Err_NetworkErr = -2, //网络错误
......@@ -20,7 +20,7 @@ enum AuthErrCode {
WechatAuth_Err_Timeout = -5, //超时
};
@protocol WechatAuthAPIDelegate<NSObject>
@protocol WechatAuthAPIDelegate <NSObject>
@optional
- (void)onAuthGotQrcode:(UIImage *)image; //得到二维码
......@@ -29,12 +29,12 @@ enum AuthErrCode {
@end
@interface WechatAuthSDK : NSObject{
@interface WechatAuthSDK : NSObject {
NSString *_sdkVersion;
__weak id<WechatAuthAPIDelegate> _delegate;
__weak id <WechatAuthAPIDelegate> _delegate;
}
@property(nonatomic, weak, nullable) id<WechatAuthAPIDelegate> delegate;
@property(nonatomic, weak, nullable) id <WechatAuthAPIDelegate> delegate;
@property(nonatomic, readonly) NSString *sdkVersion; //authSDK版本号
/*! @brief 发送登录请求,等待WechatAuthAPIDelegate回调
......
......@@ -179,7 +179,7 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
fluwxKeyPlatform: fluwxKeyIOS,
};
[fluwxMethodChannel invokeMethod:@"onPayResponse" arguments:result];
} else if([resp isKindOfClass:[WXOpenBusinessWebViewResp class]]){
} else if ([resp isKindOfClass:[WXOpenBusinessWebViewResp class]]) {
WXOpenBusinessWebViewResp *businessResp = (WXOpenBusinessWebViewResp *) resp;
NSDictionary *result = @{
......@@ -188,7 +188,7 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
errCode: @(businessResp.errCode),
type: businessResp.type == nil ? @5 : @(businessResp.type),
@"resultInfo": businessResp.result,
@"businessType":@(businessResp.businessType),
@"businessType": @(businessResp.businessType),
fluwxKeyPlatform: fluwxKeyIOS,
};
......
......@@ -6,7 +6,6 @@
//
//
#import <Foundation/Foundation.h>
#import "WXApi.h"
#import "WXApiRequestHandler.h"
#import "SendMessageToWXReq+requestWithTextOrMediaMessage.h"
......@@ -95,10 +94,10 @@
if ([StringUtil isBlank:musicURL]) {
ext.musicLowBandUrl = musicLowBandUrl;
ext.musicLowBandDataUrl = (musicLowBandDataUrl == (id) [NSNull null]) ? nil : musicLowBandDataUrl ;
ext.musicLowBandDataUrl = (musicLowBandDataUrl == (id) [NSNull null]) ? nil : musicLowBandDataUrl;
} else {
ext.musicUrl = musicURL;
ext.musicDataUrl = (dataURL == (id) [NSNull null]) ? nil : dataURL ;
ext.musicDataUrl = (dataURL == (id) [NSNull null]) ? nil : dataURL;
}
......@@ -207,7 +206,7 @@
InScene:(enum WXScene)scene {
WXMiniProgramObject *ext = [WXMiniProgramObject object];
ext.webpageUrl = (webpageUrl == (id) [NSNull null]) ? nil : webpageUrl;
ext.userName =(userName == (id) [NSNull null]) ? nil : userName ;
ext.userName = (userName == (id) [NSNull null]) ? nil : userName;
ext.path = (path == (id) [NSNull null]) ? nil : path;
ext.hdImageData = (hdImageData == (id) [NSNull null]) ? nil : hdImageData;
ext.withShareTicket = withShareTicket;
......@@ -389,7 +388,6 @@
}
+ (BOOL)sendPayment:(NSString *)appId PartnerId:(NSString *)partnerId PrepayId:(NSString *)prepayId NonceStr:(NSString *)nonceStr Timestamp:(UInt32)timestamp Package:(NSString *)package Sign:(NSString *)sign {
PayReq *req = [[PayReq alloc] init];
......@@ -400,8 +398,6 @@
req.timeStamp = timestamp;
req.package = package;
req.sign = sign;
return [WXApi sendReq:req];
......
......@@ -37,7 +37,11 @@ abstract class WeChatShareModel {
final String mediaTagName;
final WeChatScene scene;
WeChatShareModel({this.messageExt, this.messageAction, this.mediaTagName, this.scene: WeChatScene.SESSION});
WeChatShareModel(
{this.messageExt,
this.messageAction,
this.mediaTagName,
this.scene: WeChatScene.SESSION});
Map toMap();
}
......@@ -51,10 +55,20 @@ class WeChatShareTextModel extends WeChatShareModel {
final String transaction;
///transaction only works on Android.
WeChatShareTextModel({String text, String transaction, WeChatScene scene, String messageExt, String messageAction, String mediaTagName})
WeChatShareTextModel(
{String text,
String transaction,
WeChatScene scene,
String messageExt,
String messageAction,
String mediaTagName})
: this.text = text ?? "",
this.transaction = transaction ?? "text",
super(mediaTagName: mediaTagName, messageAction: messageAction, messageExt: messageExt, scene: scene);
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
messageExt: messageExt,
scene: scene);
@override
Map toMap() {
......@@ -114,7 +128,11 @@ class WeChatShareMiniProgramModel extends WeChatShareModel {
assert(webPageUrl != null && webPageUrl.isNotEmpty),
assert(userName != null && userName.isNotEmpty),
assert(path != null && path.isNotEmpty),
super(mediaTagName: mediaTagName, messageAction: messageAction, messageExt: messageExt, scene: scene);
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
messageExt: messageExt,
scene: scene);
@override
Map toMap() {
......@@ -158,7 +176,11 @@ class WeChatShareImageModel extends WeChatShareModel {
this.thumbnail = thumbnail ?? "",
assert(image != null),
this.imageData = null,
super(mediaTagName: mediaTagName, messageAction: messageAction, messageExt: messageExt, scene: scene);
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
messageExt: messageExt,
scene: scene);
WeChatShareImageModel.fromFile(
File imageFile, {
......@@ -174,7 +196,11 @@ class WeChatShareImageModel extends WeChatShareModel {
this.transaction = transaction ?? "text",
this.thumbnail = thumbnail ?? "",
this.imageData = null,
super(mediaTagName: mediaTagName, messageAction: messageAction, messageExt: messageExt, scene: scene);
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
messageExt: messageExt,
scene: scene);
WeChatShareImageModel.fromUint8List({
@required this.imageData,
......@@ -190,7 +216,11 @@ class WeChatShareImageModel extends WeChatShareModel {
this.thumbnail = thumbnail ?? "",
this.image = "",
assert(imageData != null),
super(mediaTagName: mediaTagName, messageAction: messageAction, messageExt: messageExt, scene: scene);
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
messageExt: messageExt,
scene: scene);
@override
Map toMap() {
......@@ -237,7 +267,11 @@ class WeChatShareMusicModel extends WeChatShareModel {
}) : this.transaction = transaction ?? "text",
this.thumbnail = thumbnail ?? "",
assert(musicUrl != null || musicLowBandUrl != null),
super(mediaTagName: mediaTagName, messageAction: messageAction, messageExt: messageExt, scene: scene);
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
messageExt: messageExt,
scene: scene);
@override
Map toMap() {
......@@ -287,7 +321,11 @@ class WeChatShareVideoModel extends WeChatShareModel {
this.thumbnail = thumbnail ?? "",
assert(videoUrl != null || videoLowBandUrl != null),
assert(thumbnail != null),
super(mediaTagName: mediaTagName, messageAction: messageAction, messageExt: messageExt, scene: scene);
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
messageExt: messageExt,
scene: scene);
@override
Map toMap() {
......@@ -326,7 +364,11 @@ class WeChatShareWebPageModel extends WeChatShareModel {
}) : this.transaction = transaction ?? "text",
assert(webPage != null),
assert(thumbnail != null),
super(mediaTagName: mediaTagName, messageAction: messageAction, messageExt: messageExt, scene: scene);
super(
mediaTagName: mediaTagName,
messageAction: messageAction,
messageExt: messageExt,
scene: scene);
@override
Map toMap() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论