【问题标题】:iOS13: Alternative to VOIP push notifications (enterprise) to silently communicate with an app in background now that iOS13 killed itiOS13:替代VOIP推送通知(企业)与后台应用程序静默通信,因为iOS13杀死了它
【发布时间】:2020-01-28 00:40:48
【问题描述】:

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

是否有人知道私有 API 可以绕过调用 reportNewIncomingCallWithUUID 的 pushkit 要求,这会带来全屏调用 UI,或者我无法想到的其他机制来访问即使被杀死 - Notification Service Extensions 也不起作用(我相信),因为它只适用于屏幕消息。谢谢

【问题讨论】:

  • 我非常怀疑是否有办法静默重生被杀死的应用程序。您所描述的,可能是他们发现并默默修复的错误。在用户故意杀死应用程序后启动应用程序似乎是一个安全问题。
  • 这不是一个错误,即使现在你仍然可以重生一个被杀死的应用程序,它不再是静默了。

标签: background apple-push-notifications voip ios13 enterprise


【解决方案1】:

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

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

  • 使用此gist 的内容创建一个名为PKPushRegistry+PKPushFix_m.h 的文件。
  • 将它包含在您的 swift 桥接头中。

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

【讨论】:

  • 这太棒了 - 并使用了传说中的 swizzling - 我从技术上学到的一种技术,但我自己从未真正使用过。太感谢了。我唯一的问题是,如果继续收到推送但不调用 reportNewIncomingCallWithUUID,这是否会绕过 Apple 威胁的总推送块?
  • @Nostradamus 我猜_terminateAppIfThereAreUnhandledVoIPPushes 方法也负责这个推送块。根据我的经验,这个块已经在第二次或第三次崩溃之后发生,并且只会持续大约 24 小时(卸载和安装应用程序也会重置块)。我没有对此进行足够的测试,无法确定地回答,因为在我的情况下,应用程序需要在 AppStore 中分发,但我相信是的,它绕过了它。
  • Duh - 抱歉,应该看到了!感谢您的快速回复。我一直在以编程方式将铃声音量设置为零并尽快终止呼叫,这是可用的,但这会更好。再次感谢。
猜你喜欢
  • 2015-12-30
  • 2020-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-24
  • 2018-12-20
  • 2022-01-22
  • 1970-01-01
相关资源
最近更新 更多