iOS13:替代 VOIP 推送通知(企业)以在后台与应用程序进行静默通信,因为 iOS13 已将其杀死

Nos*_*mus 2 enterprise voip background apple-push-notifications ios13

因此,在我们的企业环境中大约 4 年时间里,我们愉快地使用 VOIP 推送通知来远程访问用户的平板电脑,以进行维护和远程数据修复。与常规 APNS 不同,VOIP 推送通知即使未运行也会访问该应用程序。我应该认为苹果会在某个时候杀死它。

有没有人知道的私人API的绕过pushkit要求调用reportNewIncomingCallWithUUID 这带来全屏来电UI,或者另一种机制,我想不出来访问后台应用程序,即使被杀-通知服务的扩展赢得” t 工作(我相信)因为它只适用于屏幕消息。谢谢

pep*_*psy 5

如果你不打算发布到苹果商店,并且不关心私有 API 的使用(它可以随时更改,破坏你的代码),你可以使用 method swizzling 来更改被调用的函数的实现使应用程序崩溃的系统。

就我而言,我有一个具有 swift 和 objc 互操作性的项目。我是这样做的:

  • 创建一个PKPushRegistry+PKPushFix_m.h以此gist内容命名的文件。
  • 将它包含在您的快速桥接头中。

其他选项(也不能在 Apple Store 应用程序上使用)是使用 Xcode 10 构建它,或者从带有 iOS SDK 12 副本的 Xcode 11 手动覆盖 iOS SDK 13。


这是要点的内容,以防将来不可用:

#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
Run Code Online (Sandbox Code Playgroud)