本文介绍了iOS13:由于iOS13杀死了VOIP推送通知(企业),因此它可以在后台与应用程序静默通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 purposes. Unlike regular APNS, VOIP push notifications would access the app even if weren't running. I should have figured apple would kill it sometime.

有人知道私有API会绕过pushkit的要求来调用 reportNewIncomingCallWithUUID ,这会带来全屏调用界面,或者是我无法想到的另一种机制来访问应用程序即使被杀死也无法显示背景-通知服务扩展将不起作用(我相信),因为它仅适用于屏幕消息.谢谢

Is anyone aware of a private API to bypass the pushkit requirement to call reportNewIncomingCallWithUUID which brings about a full screen call UI, or another mechanism that I can't think of to access an app in the background even if killed - Notification Service Extensions won't work (I believe) because it will only work for screen messages. Thanks

推荐答案

如果您不打算将其发布到Apple商店,并且不关心私有API的使用(私有API随时可能更改,则会破坏您的代码),则可以使用swizzling方法更改系统调用的功能的实现,以使应用程序崩溃.

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.

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

In my case, I have a project with swift and objc interoperability. I did it this way:

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

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

这篇关于iOS13:由于iOS13杀死了VOIP推送通知(企业),因此它可以在后台与应用程序静默通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 22:22