So for about 4 years in our enterprise environment we were happily using VOIP push notifications to remotely access user\'s tablets for maintenance and remote data repair purpos
If you are not going to publish it to the Apple store, and don't care about the use of private API (which can change anytime, breaking your code), you can use method swizzling to change the implementation of the function that's called by the system to crash the app.
In my case, I have a project with swift and objc interoperability. I did it this way:
PKPushRegistry+PKPushFix_m.h
with the contents of this gist.Other options (that cannot be used on Apple Store apps as well) are building it with Xcode 10, or manually overriding iOS SDK 13 from an Xcode 11 with a copy of iOS SDK 12.
Here's the content of the gist, in case it becomes unavailable in the future:
#import <objc/runtime.h>
#import <PushKit/PushKit.h>
@interface PKPushRegistry (Fix)
@end
@implementation PKPushRegistry (Fix)
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(_terminateAppIfThereAreUnhandledVoIPPushes);
SEL swizzledSelector = @selector(doNotCrash);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
// When swizzling a class method, use the following:
// Class class = object_getClass((id)self);
// ...
// Method originalMethod = class_getClassMethod(class, originalSelector);
// Method swizzledMethod = class_getClassMethod(class, swizzledSelector);
BOOL didAddMethod =
class_addMethod(class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(class,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
[super load];
});
}
#pragma mark - Method Swizzling
- (void)doNotCrash {
NSLog(@"Unhandled VoIP Push");
}
@end