收藏
回答

iOS 18微信分享分享不出去 ?没有唤醒微信?

iOS 18微信分享分享不出去 ?没有唤醒微信?

回答关注问题邀请回答
收藏

5 个回答

  • 🥸
    🥸
    2024-10-16
    - (BOOL)g_openURL:(NSURL*)url {
        [UIApplication.sharedApplication openURL:url options:nil completionHandler:nil];
        return YES;
    }
    + (void)hookOldOpenUrl:(Class)targetCls {
        Class cls = [UIApplication class];
        if (cls) {
            Method originalMethod =class_getInstanceMethod(cls, @selector(openURL:));
            Method swizzledMethod =class_getInstanceMethod(targetCls, @selector(g_openURL:));
            if (!originalMethod || !swizzledMethod) {
                return;
            }
            IMP originalIMP = method_getImplementation(originalMethod);
            IMP swizzledIMP = method_getImplementation(swizzledMethod);
            const char *originalType = method_getTypeEncoding(originalMethod);
            const char *swizzledType = method_getTypeEncoding(swizzledMethod);
            class_replaceMethod(cls,@selector(openURL:),swizzledIMP,swizzledType);
            class_replaceMethod(cls,@selector(g_openURL:),originalIMP,originalType);
        }
    }
    
    [AppDelegate hookOldOpenUrl:AppDelegate.class];
    
        
    
    
    2024-10-16
    有用
    回复
  • 🥸
    🥸
    2024-10-16
    - (BOOL)g_openURL:(NSURL*)url {
        [UIApplication.sharedApplication openURL:url options:nil completionHandler:nil];
        return YES;
    }
    + (void)hookOldOpenUrl:(Class)targetCls {
        Class cls = [UIApplication class];
        if (cls) {
            Method originalMethod =class_getInstanceMethod(cls, @selector(openURL:));
            Method swizzledMethod =class_getInstanceMethod(targetCls, @selector(g_openURL:));
            if (!originalMethod || !swizzledMethod) {
                return;
            }
            IMP originalIMP = method_getImplementation(originalMethod);
            IMP swizzledIMP = method_getImplementation(swizzledMethod);
            const char *originalType = method_getTypeEncoding(originalMethod);
            const char *swizzledType = method_getTypeEncoding(swizzledMethod);
            class_replaceMethod(cls,@selector(openURL:),swizzledIMP,swizzledType);
            class_replaceMethod(cls,@selector(g_openURL:),originalIMP,originalType);
        }
    }
    
    [AppDelegate hookOldOpenUrl:AppDelegate.class];
    
        
    
    
    2024-10-16
    有用
    回复
  • 🥸
    🥸
    2024-10-16
    在你的appdelegate中,添加以下代码:
    - (BOOL)g_openURL:(NSURL*)url {
        [UIApplication.sharedApplication openURL:url options:nil completionHandler:nil];
        return YES;
    }
    + (void)hookOldOpenUrl:(Class)targetCls {
        Class cls = [UIApplication class];
        if (cls) {
            Method originalMethod =class_getInstanceMethod(cls, @selector(openURL:));
            Method swizzledMethod =class_getInstanceMethod(targetCls, @selector(g_openURL:));
            if (!originalMethod || !swizzledMethod) {
                return;
            }
            IMP originalIMP = method_getImplementation(originalMethod);
            IMP swizzledIMP = method_getImplementation(swizzledMethod);
            const char *originalType = method_getTypeEncoding(originalMethod);
            const char *swizzledType = method_getTypeEncoding(swizzledMethod);
            class_replaceMethod(cls,@selector(openURL:),swizzledIMP,swizzledType);
            class_replaceMethod(cls,@selector(g_openURL:),originalIMP,originalType);
        }
    }
    
    在appdelegate的方法
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中添加:
    [AppDelegate hookOldOpenUrl:AppDelegate.class];
    
        
    
    
    2024-10-16
    有用
    回复
  • 🥸
    🥸
    2024-10-16
    在你的appdelegate中,添加以下代码:
    - (BOOL)g_openURL:(NSURL*)url {
        [UIApplication.sharedApplication openURL:url options:nil completionHandler:nil];
        return YES;
    }
    + (void)hookOldOpenUrl:(Class)targetCls {
        Class cls = [UIApplication class];
        if (cls) {
            Method originalMethod =class_getInstanceMethod(cls, @selector(openURL:));
            Method swizzledMethod =class_getInstanceMethod(targetCls, @selector(g_openURL:));
            if (!originalMethod || !swizzledMethod) {
                return;
            }
            IMP originalIMP = method_getImplementation(originalMethod);
            IMP swizzledIMP = method_getImplementation(swizzledMethod);
            const char *originalType = method_getTypeEncoding(originalMethod);
            const char *swizzledType = method_getTypeEncoding(swizzledMethod);
            class_replaceMethod(cls,@selector(openURL:),swizzledIMP,swizzledType);
            class_replaceMethod(cls,@selector(g_openURL:),originalIMP,originalType);
        }
    }
    
    在appdelegate的方法
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中添加:
    [AppDelegate hookOldOpenUrl:AppDelegate.class];
    
        
    
    
    2024-10-16
    有用
    回复
  • 🥸
    🥸
    2024-10-16
    在你的appdelegate中,添加以下代码:
    - (BOOL)g_openURL:(NSURL*)url {
        [UIApplication.sharedApplication openURL:url options:nil completionHandler:nil];
        return YES;
    }
    + (void)hookOldOpenUrl:(Class)targetCls {
        Class cls = [UIApplication class];
        if (cls) {
            Method originalMethod =class_getInstanceMethod(cls, @selector(openURL:));
            Method swizzledMethod =class_getInstanceMethod(targetCls, @selector(g_openURL:));
            if (!originalMethod || !swizzledMethod) {
                return;
            }
            IMP originalIMP = method_getImplementation(originalMethod);
            IMP swizzledIMP = method_getImplementation(swizzledMethod);
            const char *originalType = method_getTypeEncoding(originalMethod);
            const char *swizzledType = method_getTypeEncoding(swizzledMethod);
            class_replaceMethod(cls,@selector(openURL:),swizzledIMP,swizzledType);
            class_replaceMethod(cls,@selector(g_openURL:),originalIMP,originalType);
        }
    }
    
    在appdelegate的方法
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中添加:
    [AppDelegate hookOldOpenUrl:AppDelegate.class];
    
        
    
    
    2024-10-16
    有用
    回复
登录 后发表内容