|
/

取消分享可以拿到回调吗

N*的雪子
发布于 5 年前
122610
移动统计 U-App

这个回调

12个回答
 
5 年前

官方应该是不提供的,Android应该可以根据获取view屏幕点击的x,y位置进行范围判断实现。

 
5 年前

从SDK接口看是没有取消分享这个Button的回调。正常业务来说来说,不太需要管理这个按钮,只需要分享平台的回调即可,如果一定要这个事件的回调,提供两个方法。

1、不要用SDK 提供的分享菜单,自定义分享菜单。

2、如果是 iOS 端可以hook这个按钮的点击事件。

可以通过 Xcode 页面调试工具知道这个按钮类名叫 UMSocialShareCancelControl 集成UIButton,然后 hook 事件方法拿到方法名 handleShareCancelControl: ,最后通过 runtime 运行时拦截到取消方法的点击。

#import "UIButton+hook.h"

#import <objc/runtime.h>


@implementation UIButton (hook)


+ (void)load{

static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{


SEL originalSelector = @selector(sendAction:to:forEvent:);

SEL swizzledSelector = @selector(xx_sendAction:to:forEvent:);


Method originalMethod = class_getInstanceMethod(self.class, originalSelector);

Method swizzledMethod = class_getInstanceMethod(self.class, swizzledSelector);

BOOL addMehtod = class_addMethod(self, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));

if (addMehtod) {

class_replaceMethod(self, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));

} else {

method_exchangeImplementations(originalMethod, swizzledMethod);

}


});

}


- (void)xx_sendAction:(SEL)action to:(nullable id)target forEvent:(nullable UIEvent *)event

{


[self xx_sendAction:action to:target forEvent:event];

if ([target isKindOfClass:[NSClassFromString(@"UMSocialShareCancelControl") class]] && sel_isEqual(action, NSSelectorFromString(@"handleShareCancelControl:"))) {

NSLog(@"--> 分享面板取消按钮");

// 这里可用通知把事件传出去


}

}


@end

 
5 年前

拿不到,无论是否分享,都是一样的返回

 
5 年前

不能吧,取消相当于直接关闭了分享框,不执行对于的回调操作

Loading ...
登录社区,分享你的经验