美文网首页iOS Developer
企业微信虚拟定位远程打卡

企业微信虚拟定位远程打卡

作者: 魔鬼分界线 | 来源:发表于2019-05-10 17:02 被阅读548次

上一家企业从指纹打卡改为企业微信打卡后就花了点时间写了一个远程打卡的插件,实现的主要功能有:1、虚拟定位;2、现场拍照改为可从相册选择照片。
安装方法:1、可以添加我的个人源 https://evildriver.github.io,里面有个WeWorkHelper企业微信助手安装就可以了;2、在WeWorkHelper资源包内部packages里面有插件包,直接使用iFunBox就可以安装。
整个插件项目在WeWorkHelper下载。
先上源码:

#import "WindowInfoManager.h"
#import "AppDelegate.h"
#import "WWKAttendanceRamdonCheckViewController.h"
#import "SuspensionView.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import "WWKAttendanceBinaryCheckViewController.h"
#import <CoreLocation/CoreLocation.h>
#import "WWKConversationLBSViewController.h"
#import "WWKMessageListController.h"
#import "HelperSettingController.h"

%hook AppDelegate

- (_Bool)application:(id)arg1 didFinishLaunchingWithOptions:(id)arg2 {
    //[[WindowInfoManager manager] addToWindow:self.window];
    return %orig;
}


%end

%hook UIImagePickerController

//设置是否从相册选择
- (void)setSourceType:(UIImagePickerControllerSourceType)sourceType {
    if ([MainKeyMananer manager].on && [MainKeyMananer manager].selectFromAlbum) {
        sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        self.mediaTypes = @[(NSString*)kUTTypeImage];
    }
    %orig;
}

//设置是否可编辑
- (void)setAllowsEditing:(BOOL)allowsEditing {
    if ([MainKeyMananer manager].on && [MainKeyMananer manager].photoEdit) {
       allowsEditing = YES;
    }
    %orig;
}


%end

%hook WWKMessageListController
//在首页添加助手设置入口
- (void)viewDidAppear:(BOOL)animated {
    %orig;

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"助手设置" style:UIBarButtonItemStylePlain target:self action:@selector(xl_setLocationClicked:)];

}

%new
- (void)xl_setLocationClicked:(id)sender {
    
    HelperSettingController *vc = [%c(HelperSettingController) new];
    [self.navigationController pushViewController:(UIViewController *)vc animated:YES];
}

%end 

%hook CLLocation

- (CLLocationCoordinate2D)coordinate {

    if ([MainKeyMananer manager].on && [MainKeyMananer manager].fakeLocation) {
        NSNumber *latitudeObj = [[NSUserDefaults standardUserDefaults] objectForKey:@"kXLLatitude"];
        NSNumber *longitudeObj = [[NSUserDefaults standardUserDefaults] 
        objectForKey:@"kXLLongitude"];

        if(!latitudeObj || !longitudeObj){
            return %orig;
        }else {
            CGFloat latitude = [latitudeObj floatValue];
            CGFloat longitude = [longitudeObj floatValue];
            CLLocationCoordinate2D coor = CLLocationCoordinate2DMake(latitude, longitude);
            return coor;
        }
    }else {
        return %orig;
    }
}

%end

MainKeyMananer主要是控制开关。

image.png
image.png
image.png
注:地图选点用的是企业微信自带的类,但为了不影响原来界面,此类为runtime动态创建的继承于自带类的子类,贴一下部分代码:
void p_send(id self, SEL _cmd, id arg1) {
    Ivar ivar = class_getInstanceVariable([self class], "_selectionItem");
    // 返回名为test的ivar变量的值
    WWKLocationItem *item = (WWKLocationItem *)object_getIvar(self, ivar);
    
    CLLocationCoordinate2D coor = item.coordinate;
    
    NSString *string = [NSString stringWithFormat:@"%lf,%lf", coor.latitude, coor.longitude];
    
    [[NSUserDefaults standardUserDefaults] setObject:@(coor.latitude) forKey:@"kXLLatitude"];
    [[NSUserDefaults standardUserDefaults] setObject:@(coor.longitude) forKey:@"kXLLongitude"];
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"kNotificationVCLoad" object:string];
    
    UIViewController *vc = (UIViewController *)self;
    [vc.navigationController popViewControllerAnimated:YES];
}

void viewDidLoad(id self, SEL _cmd) {
    //调用父类的viewdidload方法
    SEL superSel = _cmd;
    Method sm = class_getInstanceMethod([self superclass], superSel);
    IMP imp = method_getImplementation(sm);
    imp(self, superSel);
    
    UIViewController *vc = (UIViewController *)self;
    
    vc.title = @"虚拟定位";
    
    vc.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(p_send:)];
}

//runtime添加继承类
Class LocationSelectViewController = objc_allocateClassPair(NSClassFromString(@"WWKConversationLBSViewController"), "LocationSelectViewController", 0);
{
    BOOL success = class_addMethod(LocationSelectViewController, @selector(p_send:), (IMP)p_send, "V@:");
    if (success) {
        NSLog(@"添加方法成功");
    }
}

{
    BOOL success = class_addMethod(LocationSelectViewController, @selector(viewDidLoad), (IMP)viewDidLoad, "V@:");
    if (success) {
        NSLog(@"添加方法成功");
    }
}

id vc = [LocationSelectViewController new];
[self.navigationController pushViewController:(UIViewController *)vc animated:YES];

如有问题,请留言。

相关文章

  • 企业微信虚拟定位远程打卡

    上一家企业从指纹打卡改为企业微信打卡后就花了点时间写了一个远程打卡的插件,实现的主要功能有:1、虚拟定位;2、现场...

  • iOS逆向之企业微信(一)

    本文说的逆向企业微信,主要是修改了企业微信的打卡定位功能,实现了不在公司范围能也可以实现范围能打卡的功能。 (一)...

  • 企业微信精准营销策略

    一、企业微信与个人微信比较   企业微信的定位是企业与客户的沟通渠道,适合官方的,精细化运营和管理。企业微信可以直...

  • 实现虚拟定位用于远程打卡

    背景 昨天加班太晚回家,在公司忘记打卡,回家补卡之后没有了加班费,没有了全勤奖,这不是白打工了啊,越想越气,所以想...

  • 三款工具,让宅在家中的我们,不再寂寞无助!

    推荐三个办公学习工具: 1.企业微信 用企业微信远程办公,会非常高效。另外,对于管理客户的企业或者团队来说,也是个...

  • 新媒体学习小记

    微信公众号运营要点介绍 重视定位:想进行公众号定位,要考虑企业想让公众号承担什么职责,给企业微信公众号一个合适的身...

  • 使用企业微信进行会议,实现直播效果

    在疫情情况下或远程情况下,很多企业会使用企业微信进行会议。企业微信可以实现语音会议、视频会议等等,也可以共享桌面,...

  • 企业微信远程办公实践

    企业微信介绍 企业微信是腾讯出品的一款企业即时通讯软件,同时它整合了常用的企业管理工具,比如语音/视频会议,汇报,...

  • 新媒体微信的运营

    随着移动互联网的发展,微信成了新媒体发展的重要工具,其运营方式发生了变化,这其企业微信号发展,微信定位为企业和用户...

  • 竞品分析报告:飞书 VS 钉钉 VS 企业微信,移动办公哪家强?

    01 概述 竞品选择了钉钉和企业微信,原因是: 定位:飞书、企业微信、钉钉都是集成IM通讯、日程管理、办公协同和三...

网友评论

    本文标题:企业微信虚拟定位远程打卡

    本文链接:https://www.haomeiwen.com/subject/llyaoqtx.html