因此,在企业环境中使用了大约4年的时间,我们很高兴地使用VOIP推送通知来远程访问用户的平板电脑以进行维护和远程数据修复。与常规的APNS不同,即使未运行,VOIP推送通知也可以访问该应用程序。我本以为苹果会在某个时候杀死它。
有没有人知道的私有API的绕过pushkit要求调用reportNewIncomingCallWithUUID 这带来全屏来电UI,或者另一种机制,我想不出来访问后台应用程序,即使被杀- 通知服务的扩展赢得”之所以起作用(我相信)是因为它仅适用于屏幕消息。谢谢
如果您不打算将其发布到Apple Store,并且不关心私有API的使用(私有API随时可能更改,会破坏您的代码),则可以使用swizzling方法更改由调用的函数的实现系统崩溃的应用程序。
就我而言,我有一个具有快速和objc互操作性的项目。我这样做是这样的:
PKPushRegistry+PKPushFix_m.h
该要点内容命名的文件。其他选项包括使用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
这真是太棒了-并且使用了传说中的漩涡-一种我从技术中学到的技术,但从未真正使用过。太感谢了。我唯一的问题是,如果继续收到推送但不致电reportNewIncomingCallWithUUID,这是否绕过Apple威胁的总推送块?
@Nostradamus我猜该方法
_terminateAppIfThereAreUnhandledVoIPPushes
也负责此推块。根据我的经验,此块将在第二次或第三次崩溃后发生,并且只会持续大约24小时(卸载和安装应用程序也会重置该块)。我没有对此进行足够的测试就无法确定答案,因为就我而言,该应用程序需要在AppStore中分发,但是我相信是的,它绕过了它。h-对不起,应该已经看到了!感谢您的快速回复。我一直以编程方式将振铃音量设置为零,并尽快终止了该呼叫,这是有用的,但这会更好。再次感谢。
效果很好,谢谢!