Ios 目标C:通知服务扩展在iPhone 6S或更新的设备上崩溃,但在iPhone 6下工作
我已经创建了一个iOS通知服务扩展,它以前在所有设备上都能正常工作,甚至在iPhone 6s和6s+上。但从一段时间前开始,它突然在iOS 11和iOS 12上测试的所有iOS版本的iPhone 6S或更新设备上崩溃。我们可以说,它正在破坏iPhone上的3d触摸功能。调试器说允许内存分配问题12MB,并且分配的内存超过12MB。但在iOS 11和iOS 12上测试的所有iOS版本中,同样的应用程序在iPhone6s或更老的设备上运行良好 通知服务.hIos 目标C:通知服务扩展在iPhone 6S或更新的设备上崩溃,但在iPhone 6下工作,ios,objective-c,iphone,Ios,Objective C,Iphone,我已经创建了一个iOS通知服务扩展,它以前在所有设备上都能正常工作,甚至在iPhone 6s和6s+上。但从一段时间前开始,它突然在iOS 11和iOS 12上测试的所有iOS版本的iPhone 6S或更新设备上崩溃。我们可以说,它正在破坏iPhone上的3d触摸功能。调试器说允许内存分配问题12MB,并且分配的内存超过12MB。但在iOS 11和iOS 12上测试的所有iOS版本中,同样的应用程序在iPhone6s或更老的设备上运行良好 通知服务.h #import <UserNotif
#import <UserNotifications/UserNotifications.h>
API_AVAILABLE(ios(10.0))
@interface NotificationService : UNNotificationServiceExtension <UNUserNotificationCenterDelegate>
@end
有人能告诉我如何解决这个问题吗?应该复制块,而不是强烈保留。如果您使用
strong
而不是copy
,我不知道会导致什么问题,但这可能是您的问题的原因。@JonRose这是系统生成的strong
属性我没有更改它,不久前,即使我为另一个应用程序创建了一个新项目,相同的代码也可以正常工作。块应该被复制,而不是强烈保留。如果您使用strong
而不是copy
,我不知道会导致什么问题,但这可能是您的问题的原因。@JonRose这是系统生成的strong
属性我没有更改它,不久前,即使我为另一个应用程序创建新项目,相同的代码也可以正常工作。@JonRose这是系统生成的strong
属性。
#import "NotificationService.h"
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
NSLog(@"Here I want to modify my payload title but app crashes before \"didReceiveNotificationRequest\" called and allocing more than 12 MB memory on iPhone 6S or Newer Device");
}
- (void)serviceExtensionTimeWillExpire {
// [self.downloadTask cancel];
NSLog(@"serviceExtensionTimeWillExpire");
self.contentHandler(self.bestAttemptContent);
}