background - iOS13:替代 VOIP 推送通知(企业),在 iOS13 终止后与后台应用程序静默通信

标签 background apple-push-notifications voip ios13 enterprise

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

有谁知道有一个私有(private)API可以绕过pushkit要求来调用reportNewIncomingCallWithUUID,从而带来全屏通话UI,或者我无法想到的另一种机制来访问应用程序中的应用程序即使被杀死,背景也不会 - 通知服务扩展将不起作用(我相信),因为它只适用于屏幕消息。谢谢

最佳答案

如果您不打算将其发布到Apple商店,并且不关心私有(private)API的使用(它可以随时更改,破坏您的代码),您可以使用方法调配来更改函数的实现系统调用它来使应用程序崩溃。

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

  • 使用此 gist 的内容创建一个名为 PKPushRegistry+PKPushFix_m.h 的文件.
  • 将其包含在您的 swift 桥接 header 中。
<小时/>

其他选项(也不能在 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

关于background - iOS13:替代 VOIP 推送通知(企业),在 iOS13 终止后与后台应用程序静默通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59940847/

相关文章:

css - 背景还是背景颜色?

android - 当应用程序被终止并处于优化电池模式时未收到 FCM 消息|一加 5t |一加 6 |错误广播 Intent 回调 : result=CANCELLED

php - IOS GCM 推送通知在后台不起作用

android 编辑文本背景

background - svg 图像并使背景透明

ios - Firebase 推送通知不适用于 iOS

ios - 通知在 APNS 服务器上存储多长时间?

c# - 我可以使用什么库在 C# 中处理 VoIP 流?

voip - 如何在 Linksys PAP2T 上使用 SNMP?

ios - 如何在 Hybrid iOS 应用程序中实现 WebRTC?