Hack MFMailComposeViewController because I really really want it to work

This commit is contained in:
James Magahern
2021-05-25 15:38:37 -07:00
parent 22652ee05f
commit 2f40785b50
3 changed files with 84 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
//
// MFMailComposeViewControllerFix.c
// App
//
// Created by James Magahern on 5/25/21.
//
#import <CoreFoundation/CoreFoundation.h>
#import <MessageUI/MessageUI.h>
#import <objc/runtime.h>
@interface MFMailComposeViewController (InternalMethods)
+ (BOOL)canSendMailSourceAccountManagement:(NSInteger)sourceAccountManagement;
@end
static void swizzleClassMethod(Class targetClass, SEL originalSelector, IMP replacementIMP)
{
Method originalMethod = class_getClassMethod(targetClass, originalSelector);
method_setImplementation(originalMethod, replacementIMP);
}
__attribute__((constructor))
static void swizzleMFMailComposeViewController()
{
// Hacks to work around the fact that MFMailComposeViewController is broken in iOS 14+
swizzleClassMethod(MFMailComposeViewController.class, @selector(canSendMail), imp_implementationWithBlock(^BOOL(void) {
return YES;
}));
swizzleClassMethod(MFMailComposeViewController.class, @selector(canSendMailSourceAccountManagement:), imp_implementationWithBlock(^BOOL(NSInteger sam) {
return YES;
}));
}