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

send auth

上级 69a62e0d
......@@ -2,7 +2,7 @@ package com.jarvan.fluwx
import com.jarvan.fluwx.constant.WeChatPluginMethods
import com.jarvan.fluwx.constant.WeChatPluginMethods.IS_WE_CHAT_INSTALLED
import com.jarvan.fluwx.handler.FluwxLoginHandler
import com.jarvan.fluwx.handler.FluwxAuthHandler
import com.jarvan.fluwx.handler.FluwxResponseHandler
import com.jarvan.fluwx.handler.FluwxShareHandler
import com.jarvan.fluwx.handler.WXAPiHandler
......@@ -44,7 +44,7 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
}
if ("sendAuth" == call.method) {
FluwxLoginHandler.sendAuth(call, result)
FluwxAuthHandler.sendAuth(call, result)
return
}
......
package com.jarvan.fluwx.handler
import com.jarvan.fluwx.constant.WechatPluginKeys
import com.tencent.mm.opensdk.modelmsg.SendAuth
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
internal object FluwxLoginHandler {
internal object FluwxAuthHandler {
fun sendAuth(call: MethodCall, result: MethodChannel.Result) {
val req = SendAuth.Req()
req.scope = call.argument("scope")
req.state = call.argument("state")
req.openId = call.argument("openId")
result.success(WXAPiHandler.wxApi?.sendReq(req))
}
fun hehe(){
}
}
\ No newline at end of file
......@@ -5,7 +5,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import com.jarvan.fluwx.handler.FluwxLoginHandler;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
......
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
#import "FluwxShareHandler.h"
@interface AppDelegate : FlutterAppDelegate
......
......@@ -8,6 +8,7 @@
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
......
......@@ -3,7 +3,7 @@
#import "FluwxKeys.h"
@class FluwxShareHandler;
@class FluwxResponseHandler;
@class FluwxAuthHandler;
extern BOOL isWeChatRegistered;
......@@ -12,6 +12,8 @@ extern BOOL isWeChatRegistered;
@private
FluwxShareHandler *_fluwxShareHandler;
@private
FluwxAuthHandler *_fluwxAuthHandler;
}
@end
......@@ -5,6 +5,7 @@
#import "../../../../../../ios/Classes/handler/FluwxShareHandler.h"
#import "ImageSchema.h"
#import "FluwxResponseHandler.h"
#import "FluwxAuthHandler.h"
@implementation FluwxPlugin
......@@ -24,10 +25,11 @@ BOOL isWeChatRegistered = NO;
}
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
self = [super init];
if (self) {
_fluwxShareHandler = [[FluwxShareHandler alloc] initWithRegistrar:registrar];
_fluwxAuthHandler = [[FluwxAuthHandler alloc] initWithRegistrar:registrar];
}
return self;
......@@ -41,12 +43,18 @@ BOOL isWeChatRegistered = NO;
return;
}
if ([unregisterApp isEqualToString:call.method]) {
[self initWeChatIfNeeded:call result:result];
return;
}
if ([unregisterApp isEqualToString:call.method]) {
[self initWeChatIfNeeded:call result:result];
return;
}
if ([call.method hasPrefix:@"share"]) {
if([@"sendAuth" isEqualToString :call.method]){
[_fluwxAuthHandler handleAuth:call result:result];
return;
}
if ([call.method hasPrefix:@"share"]) {
[_fluwxShareHandler handleShare:call result:result];
return;
} else {
......@@ -54,21 +62,18 @@ BOOL isWeChatRegistered = NO;
}
}
- (void)initWeChatIfNeeded:(FlutterMethodCall *)call result:(FlutterResult)result {
if(!call.arguments[fluwxKeyIOS]){
result(@{fluwxKeyPlatform:fluwxKeyIOS,fluwxKeyResult:@NO});
if (!call.arguments[fluwxKeyIOS]) {
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @NO});
return;
}
if (isWeChatRegistered) {
result(@{fluwxKeyPlatform:fluwxKeyIOS,fluwxKeyResult:@YES});
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @YES});
return;
}
......@@ -80,15 +85,14 @@ BOOL isWeChatRegistered = NO;
isWeChatRegistered = [WXApi registerApp:appId];
result(@{fluwxKeyPlatform:fluwxKeyIOS,fluwxKeyResult: @(isWeChatRegistered)});
result(@{fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyResult: @(isWeChatRegistered)});
}
- (void)unregisterApp:(FlutterMethodCall *)call result:(FlutterResult)result {
isWeChatRegistered = false;
result(@YES);
isWeChatRegistered = false;
result(@YES);
}
@end
//
// Created by mo on 2018/8/23.
//
#import <Foundation/Foundation.h>
#import "CallResults.h"
#import "WXApiRequestHandler.h"
#import "FluwxKeys.h"
#import "StringToWeChatScene.h"
#import "WXApi.h"
#import "FluwxMethods.h"
#import <Flutter/Flutter.h>
#import "FluwxPlugin.h"
#import "ThumbnailHelper.h"
#import "NSStringWrapper.h"
@class StringUtil;
@interface FluwxAuthHandler : NSObject
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar;
- (void)handleAuth:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
\ No newline at end of file
//
// Created by mo on 2018/8/23.
//
#import "FluwxAuthHandler.h"
@implementation FluwxAuthHandler
- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
self = [super init];
// if (self) {
//
// }
return self;
}
- (void)handleAuth:(FlutterMethodCall *)call result:(FlutterResult)result {
[WXApiRequestHandler sendAuthRequestScope:call.arguments[@"scope"]
State:call.arguments[@"state"]
OpenID:call.arguments[@"openId"]
InViewController:nil];
}
@end
\ No newline at end of file
......@@ -18,4 +18,4 @@
@interface FluwxShareHandler : NSObject
-(instancetype) initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar;
- (void)handleShare:(FlutterMethodCall *)call result:(FlutterResult)result;
@end
\ No newline at end of file
@end
......@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import "WXApiObject.h"
#import "StringUtil.h"
#import "FluwxResponseHandler.h"
@interface WXApiRequestHandler : NSObject
......
......@@ -9,7 +9,6 @@
#import <Foundation/Foundation.h>
#import "WXApi.h"
#import "WXApiRequestHandler.h"
#import "WXApiManager.h"
#import "SendMessageToWXReq+requestWithTextOrMediaMessage.h"
#import "WXMediaMessage+messageConstruct.h"
......@@ -319,7 +318,7 @@
return [WXApi sendAuthReq:req
viewController:viewController
delegate:[WXApiManager sharedManager]];
delegate:[FluwxResponseHandler responseHandler]];
}
+ (BOOL)openProfileWithAppID:(NSString *)appID
......
class WeChatSendAuthModel {
final String scope;
final String state;
final String openId;
WeChatSendAuthModel(this.scope, this.state) :
WeChatSendAuthModel(this.scope, this.state,this.openId) :
assert(scope != null && scope
.trim()
.isNotEmpty);
......@@ -10,7 +11,8 @@ class WeChatSendAuthModel {
Map toMap() {
return {
"scope":scope,
"state":state
"state":state,
"openId":openId
};
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论